Cannot find JDK for module

Answered

I have just installed IntelliJ Idea Ultimate Edition on Arch Linux. No matter which way I try to install the JDK, I cannot manage to build a simple Java program without getting the error in the title. What should I do?

14 comments
Comment actions Permalink

Hello,

  • Do you see the JDK added to the list of available SDKs under File | Project Structure | SDKs?
  • Do you see the libraries on the JDK's 'Classpath' tab?
  • Is the JDK selected in the File | Project Structure | Project window?
  • Is the Module SDK selected correctly on the File | Project Structure | Module page > 'Dependencies' tab?

Try restarting the IDE using the File | Invalidate Caches & Restart menu option.

0
Comment actions Permalink

I do see the JDK listed there.

I do see the libraries listed on the classpath tab.

I have selected the JDK in the Project window.

I do see the module selected correctly in the dependencies tab.

I tried invalidating the cache, and it didn't fix anything.

0
Comment actions Permalink

Can you take a screenshot of the error? What path to the JDK did you specify?

0
Comment actions Permalink

 

Path is: /usr/lib/jvm/java-14-openjdk

0
Comment actions Permalink

Try the following:

  • Delete the JDK from the list of SDKs under File | Project Structure | SDKs, restart the IDE and add the JDK again
  • Download a different JDK distribution into a new different directory on your disk and add it to the IDE's SDKs
  • Exit the IDE, delete the .idea directory and <project_name>.iml file from the project directory and load the project anew via File | New | Project from Existing Sources
  • Exit the IDE and delete the IDE system directory
  • Backup and delete the IDE configuration directory

As a last resort, try downloading the latest release of IntelliJ IDEA and installing it into a new fresh directory.

0
Comment actions Permalink

I have tried everything you said. As it seems unusual, let me describe for you my installation experience:

Once I have installed it, and I launch it for the first time by typing in "idea" in the terminal, it tells me my user doesn't have the permission to write to .config/Jetbrains, even though I own the .config directory. So, when I create it the .config/JetBrains directory, it works. After going through the quick setup, it prompts me for my authentication back in the terminal. It says that "Authentication is needed to run 'home/myUser/.cache/Jetbrains/IdeaIC2020.2/tmp/launcher_installer.sh' as the super user. However, the authentication fails when I put in my correct credential. So, I manually set that .cache/Jetbrains directory to 777 permissions. Finally, it launches correctly, albeit with the following warnings in the terminal:

OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release.
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.intellij.util.ReflectionUtil to field sun.awt.X11.XToolkit.awtAppClassName
WARNING: Please consider reporting this to the maintainers of com.intellij.util.ReflectionUtil
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
2020-10-21 17:52:52,027 [ 61570] WARN - Container.ComponentManagerImpl - Do not use constructor injection (requestorClass=org.jetbrains.android.compose.AndroidComposeAutoDocumentation)
2020-10-21 17:52:52,322 [ 61865] WARN - tartup.impl.StartupManagerImpl - Activities registered via registerPostStartupActivity must be dumb-aware: org.jetbrains.kotlin.idea.configuration.ui.KotlinConfigurationCheckerComponent$projectOpened$1@7d2a4aa2
2020-10-21 17:52:54,028 [ 63571] WARN - ion.impl.NotificationCollector - Notification group 'Heap Dump Analysis' is already registered in whitelist
2020-10-21 17:52:54,028 [ 63571] WARN - ion.impl.NotificationCollector - Notification group 'Low Memory' is already registered in whitelist
2020-10-21 17:53:53,349 [ 122892] WARN - com.intellij.util.xmlb.Binding - no accessors for org.jetbrains.kotlin.idea.highlighter.KotlinDefaultHighlightingSettingsProvider
2020-10-21 17:54:56,076 [ 185619] WARN - com.intellij.util.xmlb.Binding - no accessors for org.jetbrains.kotlin.idea.scripting.gradle.GradleScriptInputsWatcher$Storage
2020-10-21 17:54:56,097 [ 185640] WARN - com.intellij.util.xmlb.Binding - no accessors for org.jetbrains.kotlin.idea.core.script.configuration.utils.ScriptClassRootsStorage

 

 

After trying to install the Community edition instead, it still gives me the same error. It doesn't matter where the project is or where the jdk is. I'm not sure how I could "install" IntelliJ to a different directory, since I am using the Arch package manager and package maker.

0
Comment actions Permalink

On IDEA side:

On Linux side:

  • What is the output of:
$ archlinux-java status
  • What package manager did you use to install IDEA? Snap?

 

0
Comment actions Permalink

I also found a similar issue posted on the Arch Linux forum, maybe it'll give you some ideas:

https://bbs.archlinux.org/viewtopic.php?id=259854

0
Comment actions Permalink

I used pacman for installing the openjdk-14, and I used makepkg to build the openjdk-15 package I cloned from the AUR. I tried specifying openjdk-14 in with that choose-runtime plugin, to no avail.

Upload id is 2020_10_23_6Q958V46bsJEA3jz . Apologies in advance for how long it is.

That other thread is also mine, and I am following through with people on the Arch side at the moment as well. Thank you for the help so far!

0
Comment actions Permalink

No problem, happy to help see it through.

Try to install IDEA via snap using the commands described here: https://snapcraft.io/install/intellij-idea-ultimate/arch, and run it as admin.

Did you check that the javac executable is in the /usr/lib/jvm/java-14-openjdk/bin directory? Are you sure you installed the JDK and not JRE?

0
Comment actions Permalink

I tried installing via Snap. It still has the same issue. My javac executable is in the /usr/lib/jvm/java-14-openjdk/bin directory. It is the JDK, not the JRE.

0
Comment actions Permalink

Hi,
I see that you have used some $HOME in below from your log.

-Djb.vmOptionsFile=$HOME/.config/JetBrains/IntelliJIdea2020.2/idea64.vmoptions
idea.config.path=$HOME/.config/JetBrains/IntelliJIdea2020.2
 
Does it help if you change them to your home folder path (like /home/your_username) directly? You could use the File | Manage IDE Settings | Restore Default Settings from the main menu to reset them.
If it doesn't help, please upload the `~/.cache/JetBrains/IntelliJIdea2020.2/log/build-log/build.log` too.
1
Comment actions Permalink

Holy cow that actually worked. I had to uninstall the snap version because it wouldn't let me change the idea.properties file, but once I followed the instructions at https://intellij-support.jetbrains.com/hc/en-us/articles/207240985-Changing-IDE-default-directories-used-for-config-plugins-and-caches-storage and replaced ${user.home} with /home/myuser, it works like a charm. It seems like a lot of applications on my machine can't recognize my home folder for some reason. Thank you so much for the help!

0
Comment actions Permalink

As far as I know, the $HOME is shell syntax. And the IDEA doesn't substitute the real home path when you using the $HOME in the above places. Try using the ~/.config/... could help here.

The IDEA may be confused by $HOME here or some parts of the tools like compiler don't work well with this path.

0

Please sign in to leave a comment.