IntelliJ - java: Cannot find JDK '1.8' - java

Update: Not sure why this is marked as a duplicate. I had already linked to the other post stating that none of the suggestions / answers work for me. In addition, their question seems to be related to an issue using Windows VMs via Mac, which is irrelevant for me.
I am using IntelliJ IDEA 14.0.3. I have selected the 'Java Hello World' sample. When I try and run the program I receive the error: "Error: java: Cannot find JDK '1.8' for module 'Deliverable4'. I have tried every single suggestion from this post intellij - java: Cannot find JDK '1.7' for module but still can't this to work. Any help would be greatly appreciated.

Go to:
File => Project structure
And check: Project, Modules and SDKs tabs:
If at SDKs Java 1.8 Sdk isn't selected just add it.
And press OK.

I suddenly started seeing this issue when upgrading my Java SDK from 1.8 to 10.
I went to File > Project Structure > SDKs, JDK home path was in red so I clicked the folder icon to the right of the path.
Even though the Finder window that popped up already had me in the correct directory /Library/Java/JavaVirtualMachines/jdk-10.0.2.jdk/Contents/Home (maybe it dropped me wherever my newly updated classpath said Java was?), the path that was displayed in red wasn't the same as that path. Instead, it was using the old one, something like /Library/Java/JavaVirtualMachines/jdk-1.8_(???)/Contents/Home. Clicked OK and the JDK home path was updated to the correct directory, clicked Apply/OK and everything was fine after that.
For reference,
IntelliJ IDEA 2018.2.1 (Community Edition)
Build #IC-182.3911.36, built on August 6, 2018
JRE: 1.8.0_152-release-1248-b8 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
macOS 10.12.6

Updating from IntelliJ version 14.0.3 to 14.1 seemed to fix the problem.

If the update solution given above doesn't work for somebody, consider not using the bin directory like the one used in the PATH environment but rather the java root directory. In short instead of:
path_to_java_folder\java\bin\
use:
path_to_java_folder\java\
and everything will work just fine.

Related

InteliJ Mac Catalina: Java 11 or newer is required to run the IDE

Hello yesterday I updated my IntelliJ ide to the latest version (2020.3.2). The problem is that it's not starting anymore. When I try to open it, I get this error message:
I have two JDKs, 8 and 12
It seems like InteliJ does some kind of lookup by alphabetical order because when I rename my jdk 8 to other name that goes after the "jdk-12..." it actually works
The problem is that have to rename the folders and then return the original names to make my projects work, is there a way to avoid this renaming? Thanks a lot
This IntelliJ IDEA version requires Java 11 to run.
You override default bundled JetBrains Runtime with Java 8.
The solution is to remove this override. It's either idea.jdk file in the configuration directory or an environment variable as described in this document:
~/Library/Application Support/JetBrains/IntelliJIdea2020.3/idea.jdk
Note that JDK used to run IntelliJ IDEA itself is not related to the JDK that you are using to build and run your own projects. These two can be different.
I bumped into this issue with my PyCharm. In that case, pycharm.jdk was the one we need to remove.
~/Library/Application Support/JetBrains/PyCharm2020.3$ mv pycharm.jdk /tmp
Hope it helps someone came here by google.

Android Studio: "Gradle sync failed: Could not run JVM from the selected JDK."

Ever since installing Android Studio 3.2, I haven't been able to run Java, I have tried jdk-8u181-windows-x64, jdk-10.0.2_windows-x64_bin, jdk-11_windows-x64_bin, setting PATH and reinstalling everything umpteen times, the result is the same - no "java" appears and the error message is: -
Gradle sync failed: Could not run JVM from the selected JDK.
Please ensure JDK installation is valid and compatible with the current OS (Windows 8.1 6.3, amd64).
If you are using embedded JDK, please make sure to download Android Studio bundle compatible
with the current OS. For example, for x86 systems please choose a 32 bits download option. (369 ms)
Notes: I used to be able to open the java folder but after playing with it too much, something went wrong, so, I decided to start afresh... and I am dead ever since.
Is Studio 3.2 flawed? Not compatible with Java at all? Or am I missing something? is there a older Android Studio I can test? Thanks for any help you may provide.
In my case, the following solved it:
File->Other settings->Default Project Structure...
In "JDK Location", I previously had the oracle jdk selected. To fix this issue, I instead checked "Use embedded JDK (recommended)"
Solved YES
Other Settings ---> Default Project Structure ---> Uncheck Embedded jdk ( Write Your Own jdk Location )
In my case, the following solved it:
File->Other settings->Default Project Structure...
setting the JAVA_HOME environment variable to C:\Program Files\Java\jdk1.8.0_181
my JDK Source File
Try setting your SDK location. I had the same problem with Android Studio 3.2 (but I also switched to openjdk, so that could be the source of my problem). Anyway, after pointing SDK location to the root of my JDK it worked like a charm.
To change SDK location click on the Android project Window and then press F4. In the new Window choose SDK location and set it to point to the root of your JDK.
i got mine working by setting the JAVA_HOME environment variable to C:\Program Files\Java\jdk1.8.0_181\bin my jdk folder

Can't seem to get JavaFX to work with Java 10 JDK and Gradle

I have a JavaFX app that I build with Gradle and Java 8. I recently got a new laptop and installed Java 10 JDK instead of Java 8 and didn't think it'd be a big deal. However, when I try to import the Gradle project into Intellij I get this error:
org.gradle.api.ProjectConfigurationException: A problem occurred configuring root project 'MyProject'
Caused by: org.gradle.api.GradleException: Couldn't find Ant-JavaFX-library, please make sure you've installed some JDK which includes JavaFX (e.g. OracleJDK or OpenJDK and OpenJFX), and JAVA_HOME is set properly.
at de.dynamicfiles.projects.gradle.plugins.javafx.JavaFXGradlePlugin.addJavaFXAntJARToGradleBuildpath(JavaFXGradlePlugin.java:112)
More....
I have set JAVA_HOME in the Windows env vars to this path:
C:\Program Files\Java\jdk-10.0.1
How can I solve this problem?
Thanks!
Thanks for the comment feedback on this post I was able to find the problem. I first verified that the JDK 10 installation did drop off ant-javafx.jar into the lib/ dir in JAVA_HOME. It did..!
So it must be Gradle or Intellij.. right? Well there's only one super easy way to build a JavaFX gradle project at the moment and that's with javafx-gradle-plugin. Looking up the repo I can see the last release was a year ago! RED FLAG! Looking through the code I found a pathing check for a now defunct relative path that drops the verbatim error above.
So I submitted a Pull Request to the developer of the project and hopefully that resolves the issue..
That's here: https://github.com/FibreFoX/javafx-gradle-plugin/pull/128 .
In the meantime, I solved locally by copying ant-javafx.jar from it's real path at C:\Program Files\Java\jdk-10.0.1\lib\ant-javafx.jar out into C:\Program Files\Java\lib\ant-javafx.jar. Then I rebuilt the Gradle project and everything worked accordingly, confirming the solution in the PR above.
If you're building JavaFX apps with Gradle right now, you're likely to encounter this issue until the developer fixes it. He claims he's working on a brand-new plugin right now but the last release of this widely used plugin was over a year ago.
Thanks!

Issue JDK creating a scala project in Intellij

I have installed the JDK jdk-8u144-windows-x64.exe in my computer in order to set up the tool IntelliJ to play with Scala, well before move forward to IntelliJ installation I ensured the JDK in my computer:
running path:
the running a java version:
Then, I installed the IntelliJ and the Scala plugins, so when finally I'M going to create my first project my laptop configuration is not mapping the JDK:
I tried to add the required environment just clicking on new and go thru the path where I installed the jdk but it doesn't go thru either.
Please, guys, I'm a bit nooby with Scala and IntelliJ, could you please guide me a bit. I tried to follow the instructions in this link but it is not going thru. https://www.scala-lang.org/documentation/getting-started-intellij-track/getting-started-with-scala-in-intellij.html
thanks
Make sure you have set environment variable JAVA_HOME to your java directory, IntelliJ detects JDK using that environment variable, or you can browse the path of java installation directory using "New" button beside jdk and select it.

IntelliJ not recognising JDK version

I have write one java project on IntelliJ idea 8.1.1.When I go to compile option of IntelliJ IDEA 8.1.1 then it shows pop-up message box, in that it shows error-
cannot determine version for JDK
Update JDK configuration.
Even though I have proper JDK version, I have jdk1.5.0 installed in my PC working properly with other environment.
Please suggest any settings that I may need to change.
I got this same error message just recently in IntelliJ IDEA 9.0.4. "Cannot Detect JDK Version", "Probably JDK installed in C:\Program Files\Java\jdk1.6.0_24 is corrupt."
I was able to solve it by removing the JDK from Project Structure | SDKs and then re-adding it.
What is the output of the "java -version" for this JDK installation? It could be that the output contains some non-standard strings before the actual version information. Such strings can be added by the environment variables on your system. IDEA may not be able to parse this output and detect the JDK version correctly.

Categories