IntelliJ IDEA can't setup JDK - java

I'm trying to setup JDK in IntelliJ IDEA and whatever I do, or whatever JDK version I select, nothing happens. The following situation remains:
So I told IDEA what JDK it should use, but it still asks me to setup a JDK. Is this a bug or am I missing something? Can I apply any workaround to make everything work as usual?
ADDITION
The steps which I go through setting up the JDK:
situation before setting up:
the first step:
the second step:
the third step:
the situation after setting up JDK:
SDKs:
module settings:

File | Invalidate Caches is the first thing you should try in case of such issues.

Select your modul in the "Project View" and press F4 in the "Project Setting"select "Module".
In the "Module Settings" overview you can add/remove the Modul SDK.

Following this worked for me :
Select your module in Project View
Press F4
Go to SDK
Select you SDK
Make sure you have various jars in there. Else, select proper directory.
In my case, even though correct directory was selected classpath,sourcepath etc were empty.
So I had to select jdk installation directory one more time, which loaded all the jars and solved the problem.

In my case just File | Invalidate Caches and Restart did not work. Upon Right clicking the project and going to Module Settings , I had no SDK selected under Project Settings->Project.

I followed below steps
Press F4
Select Modules in Project Settings
Set up Module SDK from the drop down or add the new one.
Apply & OK

For someone like me, looking for a way to setup an offline documentation in IDEA on UBUNTU Linux. You should install the openjdk-8-doc (or openjdk-X-doc in general case) package, then go to File|Project Structure|SDKs|1.8(still 1.X in general), then select tab Documentation Paths and add the path /usr/lib/jvm/java-1.8.0-openjdk-amd64/docs/api there.
Note, that path of Java docs installation may differ on your machine. You are able to check the path of Java docs installation executing dpkg-query -L openjdk-8-doc | less in a shell.

I was seeing this exception in the console:
NoClassDefFoundError: com/intellij/remote/RemoteSdkConnectionAcceptor
which was caused by the python community edition plugin on Intellij IDEA 2016.2.5.
After updateing/disableing the plugin, I was able to setup the SDK again.

Related

IntelliJ: Cannot resolve symbol 'String' [duplicate]

What are common causes for IntelliJ IDEA not being able to resolve built-in JVM types and methods? For example, when I mouse over String the tooltip says "Cannot resolve symbol 'String'". It's as if IntelliJ has doesn't know where the JVM is.
By the way, I am running OS X 10.6.6. Everything was working fine until I ran the system update this morning.
Most likely JDK configuration is not valid, try to remove and add the JDK again as I've described in the related question here.
First check if you have configured JDK correctly:
Go to File->Project Structure -> SDKs
your JDK home path should be something like this:
/Library/Java/JavaVirtualMachine/jdk.1.7.0_79.jdk/Contents/Home
Hit Apply and then OK
Secondly check if you have provided in path in Library's section
Go to File->Project Structure -> Libraries
Hit the + button
Add the path to your src folder
Hit Apply and then OK
This should fix the problem
I was facing the same problem when import projects into IntelliJ.
for in my case first, check SDK details and check you have configured JDK correctly or not.
Go to File-> Project Structure-> platform Settings-> SDKs
Check your JDK is correct or not.
Next, I Removed project from IntelliJ and delete all IntelliJ and IDE related files and folder from the project folder (.idea, .settings, .classpath, dependency-reduced-pom). Also, delete the target folder and re-import the project.
The above solution worked in my case.
For me, I had to remove the intellij internal sdk and started to use my local sdk. When I started to use the internal, the error was gone.
I tried almost everything but nothing was helping with the ibm jdk 1.8. to fix this issue. then I found an article from https://youtrack.jetbrains.com/issue/IDEA-279214/Cannot-resolve-symbol-String-when-using-IBM-JDK-180 and it worked like charm!!!
so sharing original help credit goes to #Serge Barano. incase anybody needs and not able to able to resolve the issue using previous solutions like me.
according to the article answer is:
IBM JDK has a weird layout and the jar with the String class is in bin directory for some reason:
d:\dev\ibm_sdk80\jre\bin\default\jclSC180\vm.jar
If you add it to the JDK classpath in IntelliJ IDEA, the issue should resolve:
For me, IntelliJ could autocomplete packages, but never seemed to admit there were actual classes at any level of the hierarchy. Neither re-choosing the SDK nor re-creating the project seemed to fix it.
What did fix it was to delete the per-user IDEA directory ( in my case ~/.IntelliJIdea2017.1/) which meant losing all my other customizations... But at least it made the issue go away.
First of all you should try File | Invalidate Caches and if it doesn't help, delete IDEA system directory. Then re-import the Maven project and see if it helps.
For me ,
File -> project structure -> Project Language Level (11) selection worked. Local variable syntax for lambda paramters.
In my case, cloning repo from the remote was the easiest way to solve this issue.

cannot resolve symbol javafx.application in IntelliJ Idea IDE

I tried to create a JavaFX application in IntelliJ Idea IDE but I got compile error that said:
java: package javafx.application does not exist.
I have changed the Project SDK and the Project Language Level to Java 8, reloaded the project but it didn't help. Then I checked if JavaFX plugin was enabled in the settings.
The search on Google and StackOverflow didn't give me more ideas of what is wrong.
Thank for any help in advance.
P.S. I am using IntelliJ Idea 14.0 with java8.1.0_25 on archlinux OS.
As indicated here, JavaFX is no longer included in openjdk.
So check, if you have <Java SDK root>/jre/lib/ext/jfxrt.jar on your classpath under Project Structure -> SDKs -> 1.x -> Classpath? If not, that could be why. Try adding it and see if that fixes your issue, e.g. on Ubuntu, install then openjfx package with sudo apt-get install openjfx.
This should be your perfect solution. Try and enjoy.
If some command does not work properly that means if you get any error, try to solve it yourself. I have given you the main thing you need. If your application is in a different location, or your system architecture is different, solve it yourself. It's very easy to do it. Just follow my given solution.
Step 0:
sudo apt-get install openjdk-8-jre
Step: 1
sudo apt-get install openjfx
Step 2:
sudo cp /usr/share/java/openjfx/jre/lib/ext/* /usr/lib/jvm/java-1.8.0-openjdk-amd64/lib
Step 3:
sudo cp /usr/share/java/openjfx/lib/* /usr/lib/jvm/java-1.8.0-openjdk-amd64/lib
Step 4:
sudo chmod 777 -R /usr/lib/jvm/java-1.8.0-openjdk-amd64
now open a new project or rebuild your project.
Good luck.
You can use the one that comes with IntelliJ: <intellij>/jre64/lib/ext/jfxrt.jar.
You need to download the java-openjfx package from the official Arch Linux repos. (Also, make sure you have the openjdk8-openjdk package). After doing that, open your project in Intellij and go to Project-Structure -> SDKs -> 1.8 -> Classpath and try removing the old JDK you had and clicking on the directory for the new JDK that will now contain jfxrt.jar.
Another way to resolve the problem :
Click the left mouse's button on the project folder in the project structure at the left, and click on "open module settings" in the list of actions
In the new windows, click on SDKs which is under the menu title "Platform settngs"
Then check on the "Classpath" list if you can find the jfxrt plugin path, if not, click on the + symbol on the right and select the repertory of the jfxrt plugin (C:\Program Files\Java\jdk1.8.0\jre\lib\ext\jfxrt.jar on my desktop)
Sample Java application:
I'm crossposting my answer from another question here since it is related
and also seems to solve the problem in the question.
Here is my example project with OpenJDK 12, JavaFX 12 and Gradle 5.4
Opens a JavaFX window with the title "Hello World!"
Able to build a working runnable distribution zip file (Windows to be tested)
Able to open and run in IntelliJ without additional configuration
Able to run from the command line
I hope somebody finds the Github project useful.
Instructions for the Scala case:
Additionally below are instructions that work with the Gradle Scala plugin, but don't seem work with Java. I'm leaving this here in case
somebody else is also using Scala, Gradle and JavaFX.
1) As mentioned in the question, the JavaFX Gradle plugin needs to be set up.
Open JavaFX has detailed documentation on this
2) Additionally you need the the JavaFX SDK for your platform unzipped somewhere.
NOTE: Be sure to scroll down to Latest releases section where JavaFX 12 is (LTS 11 is
first for some reason.)
3) Then, in IntelliJ you go to the File -> Project Structure -> Libraries, hit the ➕-button and add the lib folder from the unzipped JavaFX SDK.
For longer instructions with screenshots, check out the excellent Open JavaFX docs for IntelliJ I can't get a deep link working, so select JavaFX and IntelliJ and then Modular from IDE from the docs nav. Then scroll down to step 3. Create a library. Consider checking the other steps too if you are having trouble.
It is difficult to say if this is exactly the same situation as in the original question, but it looked similar enough that I landed here, so I'm adding my experience here to help others.
You might have a lower project language level than your JDK.
Check if:
"Projeckt structure/project/Project-> language level" is lower than your JDK.
I had the same problem with JDK 9 and the language level was per default set to 6.
I set the Project Language Level to 9 and everything worked fine after that.
You might have the same issue.
In IntelliJ Idea,
Check the following things are configured properly,
Step 1:
File -> Setting -> Plugins -> search javafx and make sure its enabled.
Step 2: Project Structure (Ctrl+Shift+Alt+s)
Platform Settings -> SDKs -> 1.8 -> Make sure Classpath should have "jre\lib\ext\jfxrt.jar"
Step 3:
Project Settings -> Project -> Project SDK - should be selected 1.8
Project Settings -> Project -> Project language level - configured as 8
Ubuntu: If not found jfxrt.jar in your SDKs then install sudo apt-get install openjfx
If you are working with IntelliJ and JDK 11
1. go to project structure ctrl + alt + shift + s.
2. add the mising
javafx libraries in the Global Libraries section.
3. add a module-info.java file with the required dependencies to your module.
module modulename {
requires javafx.fxml;
requires javafx.controls;
opens sample;
}
4. rebuild the project !
5. enjoy !
I had the same problem, in my case i resolved it by:
1) going to File-->Project Structure---->Global libraries
2) looking for jfxrt.jar included as default in the jdk1.8.0_241\lib (after installing it)
3)click on + on top left to add new global library and i specified the path of my jdk1.8.0_241 Ex :(C:\Program Files\Java\jdk1.8.0_241).
I hope this will help you
I am using apache maven with java 11 and I was able to remove all java fx problems by adding this dependency to my pom.xml file:
<!-- JAVA FX -->
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>17.0.1</version>
</dependency>
For me the simplest solution was to use Amazon Corretto, it is pretty much same as Oracle java.
Follow the steps:
Go to Intellij, File -> Project Structure
Go to SDK
Download SDK
From the dropdown, choose 1.8 as Java 1.8 version comes bundled with JavaFX library.
And you are good to go.
I had a similar issue, my error message was slightly different though:
java: package javafx.event does not exist
I found one solution to fix this issue. Instead of adding dependencies, modifying CLASSPATH or trying different JDK / SDK versions, you can simply select:
File -> New Project -> JavaFX -> Location of the code
After restarting, the build is successful.

PhoneGap Android "Could not find *.apk" [duplicate]

I know this question has been asked before and I have seen a plethora of solutions out there, yet none seem to work for me. I was able to build my apk without issues until this error started cropping up. I have tried cleaning my project, removing it from the workspace and reimporting it, removing "Java Builder" from my Builders for the project, building the project manually, reordering my java build path. I have no visible compiler issues and no problems exist in my workspace.
I did experience this issue before and solved it once by removing the project form my workspace and re-importing it and another time I solved it by removing "Java Builder" from my java build path. None seem to work this time. I currently have most of the settings set back to default (i.e. java build is checked again).
I am running windows 7 (64 bit) and using jdk1.6.0_21 via Eclipse 3.6.
Any suggestions would be greatly appreciated as I have lost loads of development time troubleshooting this already.
[Update] My locale is English & I have tried removing the debug.keystore, United States as related to issue 834
Please follow these steps; this might help you out:
Right-click your app project and go to Properties
Select Android from left-hand side list
Uncheck the "Is Library" checkbox
If your app project relies on library projects which are in your workspace, those of course need to have the "Is Library" box checked.
deleting the R.Java file in /Gen folder did the trick for me
I tried all the above solutions. but it didn't work.
The solution was to restart eclipse !!!!!!!
hope this will help someone :)
In my case this problem started after eclipse updated the plugin with the v4.0 API release. I fixed it by going to the main preferences for Eclipse and under Android->Build uncheck 'Skip packaging and dexing until export or launch'
Note: if you eclipse gives you the Unknown Command 'crunch' error then follow this post
I've tried to gather the best of other peoples answers into a step by step list of things to try in order:
Check the project is not set as a library:
Go to Project->Properties
Select Android from left-hand side list
Uncheck the "Is Library" checkbox
Clean and rebuild the project - this should delete and recreate the entire gen folder, including the R.java file mentioned in some peoples answers
Check eclipse and all the Android plugins are up to date
Close the project, exit Eclipse, reopen eclipse, reopen the project.
Go to Java Build Path > Projects and check for any incorrect project dependencies
Go to the main preferences for Eclipse and under Android->Build uncheck 'Skip packaging and dexing until export or launch'
Check JAVA_HOME is set correctly. Follow the steps in this article
If you complete the above list, and still haven't solved the issue, please leave a comment, or if you find something else that works, feel free to edit the answer and add your thing in.
Delete the project from your workspace & import again.
This worked for me.
Can't believe similar issue has been there since 2008.
http://code.google.com/p/android/issues/detail?id=834.
i'm no expert, but eclipse on Windows, doing android apps, refuses to create the default.properties file (in the app root directory). I've just copied one from another app and it works fine. Simple contents, for Android 2.2 project it just says (ignoring comments):
target=android-8
fwiw
I was having the same issue as the OP except that all these suggestions did not work. I found a solution for me.
Make sure that "Skip packaging and dexing until export or launch." is selected.
Go to Window -> Preferences -> Android -> Build. Just make sure that option is selected and apply.
I know this does not make a lot of sense, but having it unselected was giving me this error and with it selected it goes away and the apk is installed.
I am using the auto generated ant build script from android and ONLY using it as my build process in eclipse. I am not using any other build methods.
I figured it out. I was referencing JavaSE-1.5 and using JDK 1.6. I changed it to use 1.6 and that appears to fix it.
Seems like through my research that is an overloaded error message that covers a lot of error cases.
I just fixed this by reselecting a default JRE for the execution environment (JRE6 for JavaSE-1.6 in my case). It got unchecked for some reason.
This fixed my problem. I kept getting the console error in eclipse "Could not find com_android_vending_licensing.apk" and even though it didnt seem to effect the way my app ran, it was annoying. So going into the com_android_vending_licensing project properties and unchecking the "is library" option, building the project to produce the needed apk and then going back into the com_android_vending_licensing project properties and re checking the "is library" check box fixed the problem.
Run Eclipse as "Administrator" and then import the project.
None of these things worked for me. I'm trying to access native code through the jni, first with NDK samples. What I found was the build won't run if jarlist.cache is not present in the project bin directory. If I copy one from another project to that location (may need to refresh to see the folder in Eclipse), build works every time.
Clean the project and it will do. Sometimes it happens unknowingly but keep trying to solve using diff methods.
I had somehow done a Run configuration as a Java application instead of a Android.
the problem for me was I was trying to use IBM RAD which appears to not work properly for this, I installed Eclipse and now have a different error but I should be able to get past it
On my machine (Windows7, 64bit) I could fix this by setting my execution environment to a 32bit variant of the jdk (I used 1.6.0_23). And I tried a lot of things before...
SHA1's answer did it for me: after updating to the latest sdk/adt, my project refused to build an apk; unchecking the option resolved the issue.
I don't know if the update checked this, or if it was checked before but the new adt screwed things up, but things work again now :)
In my case this worked :
Delete R.Java file in /Gen folder
+
Delete all "R.Android" imports that Eclipse added to some of my java classes !!!
and rebuild the project.
remove -- R.java -- Clean the project and run again.. this worked for me ..
Find the project's folder in your system, enter it's Properties via context menu and deselect "Read only" option. Worked in my case.
This seems to be the source of the problem in many cases, moreover some solutions up there base on copying/rewriting the files in the project what makes them non-read-only.
This is caused by JAVA_HOME not being set correctly. It can be easily resolved by following the steps in this article.
Mine was caused by this problem (incompatibility between ADT and SDK), and was fixed thus:
Eclipse > Help
Install New Software
Add 'https://dl-ssl.google.com/android/eclipse/' to 'Work With'
section and press enter
After developer tools appears on the list, check it and click Next
Restart eclipse once download is finished
I my case, I had to switch from API 21 to API 19, clean and build and everything was fine again. I am using a Mac and apparently API 21 is not fully supported on Yosemite.

How to avoid "Refreshing external Folders" in Android development in Eclipse

I am having this annoying problem which takes 10-20 seconds and sometimes more every time my android project is refreshed or rebuilt.
I searched for android forums and also in stackoverflow and but solutions does not make sense. Please give me the solution or link to it.
My android project depends on two external java libs and android libs. Tell me if you need more info.
Earlier I asked this question and it solved the problem by removing 'source attachment'. But I believe it is not a good solution because I need source to be attached with jar. It helps while debugging, code browsing. If source is not attached then, your breakpoint stops there and you can't go in readable source.
Better Solution Needed. Is there a launcher option? which disables when app launched. or build options?
Instead of attaching a source folder to the .jar file, you should zip the source folder and attach the zipped file to the .jar.
See this answer for more info https://stackoverflow.com/a/9699242/637754
The reason for this is that you have attached source with your dependent jars. Just the remove the source from the class path. This how it can be done.
Right click on the project -> Select Build Path -> Configure Build Path.. -> Select Libraries
Select the Source attachment and Remove button will highlight. Press Remove and OK.
I think that should fix your issue.
this helped me so you can try too:
Go to your Workspace root/.metadata/.plugins/org.eclipse.jdt.core/ and remove .org.eclipse.jdt.core.external.folders folder
it contains .project file with links to external folders which takes too long to refresh
You can disable "Refresh on access" option in Window->Preferences->General->Workspace - it have no effect as I think, because even it's turned on you must manually refresh projects if you modify them outside of Eclipse
If anything else fails (my case), install a fresh copy of Eclipse Juno
Go to Help-Install Software, and add this repo:
https://dl-ssl.google.com/android/eclipse/
Check all options and install.
For migration reasons I was trying to install Eclipse on MAC OS Yosemite, since Android Studio is now the official IDE, it is hard to find Eclipse setups with the ADT plugin included. I tried several versions of Eclipse, and JUNO did the work.

Your active platform is: JDK_1.6, but the corresponding property "platforms.JDK_1.6.home" is not found in the project's properties files

I'm a Java noob (but have been programming for 25+ years, and have worked with OO languages from day 1).
All of a sudden I started getting this error:
Your active platform is: JDK_1.6, but the corresponding property "platforms.JDK_1.6.home" is not found in the project's properties files.
Not sure what caused this condition, and not sure what Java's asking me to do. I'm working in the NetBeans IDE. The last thing I attempted to do is add some binary (image) resources to my project.
In my case the JDK setup in Netbeans was fine. It was just one of those strange Netbeans issues that come out of nowhere.
My fix was:
Clear the Netbeans Cache i.e. delete the folder:
C:\Users\\AppData\Local\NetBeans\Cache\
It means you haven't told netbeans where your Java 1.6 installation is. Go into settings, add the JDK (JDK->Add->New), and select the directory above 'bin' for your JDK16.
This error can occur at two scenarios:
Right click your netbean project -> Properties -> Libraries
After select Libraries , right panel on top you can see "Java Platform" combo box. This Jave Platform is missing for your project. You need to add using Manage Platforms bottom beside Jave Platform combo box.
Even thought scenario (1) is correct it can happen. Because your project has reference to another netbean project in your Libraries. This reference project is missing Jave Platform.
I have Linux in my office and Mac in Home and this problem is frequently when I share projects in github, I solve it removing the build directory and doing clean and build.
Right click on project - Properties - Libraries - Select the correct jdk version from the Java Platform combobox.
NetBeans bug
If your project depends on other projects, open and clean build all of them(that fixed it for me).
Most likely cache-related stuff. Clean up NB cache as suggested by someone before
You should remove the files under private folder in the nbproperties folders.
for me any recommended way early didn't helped, but changing in project Properties -> Source/Binary format to JDK 7, Save than change back to JDK 8 fixed this error

Categories