Cannot find JDK for module
已回答
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?
请先登录再写评论。
Hello,
Try restarting the IDE using the File | Invalidate Caches & Restart menu option.
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.
Can you take a screenshot of the error? What path to the JDK did you specify?
Path is: /usr/lib/jvm/java-14-openjdk
Try the following:
As a last resort, try downloading the latest release of IntelliJ IDEA and installing it into a new fresh directory.
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.
On IDEA side:
On Linux side:
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
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!
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
javacexecutable is in the/usr/lib/jvm/java-14-openjdk/bindirectory? Are you sure you installed the JDK and not JRE?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.
Hi,
I see that you have used some $HOME in below from your log.
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!
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.
I just had this error after adding a .sdkmanrc file to a project with
java=21.0.3-tem
It kept saying it couldn't find the sdk during the build even though it was visible in the project settings. Invalidating cache did not help. I had to export my settings, open the project, then import my settings and restart and everything is good. I lost my most recently used project on the home screen in the process but not the end of the world.
So, the root issue for all of this was that one of the startup scripts of my system bound my config directory to the *literal* path “$HOME/.config”, not substituting $HOME for /home/user. This meant that nothing on my system that tried to set a config was able to access it again after writing it (and also meant that I had a million folders called “$HOME” all over my system). All that to say, I doubt anyone will find my specific issue symptoms / parameters useful 😆
I had the same issue, that happened after every IDE update. It turned out to be an issue with the settings synchronisation.
Maybe my finding will help other people to fix the issue. Noteworthy: I do use the deprecated Sync Repository Plugin.
When using the Sync Repo functionality all JDK are stored in
%APPDATA%\JetBrains\IntelliJIdea<Version>\settingsRepository\repository\jdk.table.xml. I checked the XML and content is fine. Also the reference on the JDK inside the project files (mainly<projectdir>\.idea\misc.xml) is correct.However IntelliJ seems to have a seperate copy of all settings under
%APPDATA%\JetBrains\IntelliJIdea<Version>\options. Thejdk.table.xmlthere suddenly was missing some of the JDK entries. Copying the originaljdk.table.xmlfrom the settings repository checkout fixed the issue instantly, even without a restart.And it's sad that they deprecated that plugin. It's the best way to synchronize for teams that want to share settings.
I had the same issue with deprecated Sync Repository Plugin on MacOS and new Java 24. After disabling the plugin Idea was able to see new JVMs.