You are not logged in.

#1 2020-10-14 21:50:18

origamisith
Member
Registered: 2020-07-13
Posts: 23

IntelliJ IDEA won't recognize JDK

I have recently installed IntelliJ IDEA and OpenJDK 15. When I try to compile my barebones Java program, it throws the error

 java: Cannot find JDK 'openjdk-15 for module 'myProgram'

. I have made sure that JDK 15 is enabled in the preferences where it should be. I have uninstalled / reinstalled IntelliJ and multiple versions of the JDK. I have invalidated the cache and restarted. What should I do?

Offline

#2 2020-10-15 10:05:52

Lone_Wolf
Member
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 8,484

Re: IntelliJ IDEA won't recognize JDK

Latest openjdk version in repos is 14 , I also don't see an openjdk 15 pacakge in AUR .

How did you install openjdk 15 ?

please post output of

$ archlinux-java status

Multi-init booting with apg Openrc and systemd coexisting
Automounting : not needed, i prefer pmount
Aur helpers : makepkg + my own local repo === rarely need them

Offline

#3 2020-10-15 22:40:51

origamisith
Member
Registered: 2020-07-13
Posts: 23

Re: IntelliJ IDEA won't recognize JDK

So when I wrote the question, I was trying 15. Now, I'm trying 14, directly from the AUR. Same problem. I am able to compile and run from the command line, but not with the IntelliJ Build / Run features. Output of

archlinux-java status

is:

Available Java environments:
  java-14-openjdk (default)

Of course, the error message has updated to reflect the different JDK.

java: Cannot find JDK '14' for module 'MyProgram'

According to IntelliJ. the JDK home path for JDK '14' is /usr/lib/jvm/java-14-openjdk, and the classpath tab shows many java.* and  jdk.* files.

Offline

#4 2020-10-17 22:06:19

origamisith
Member
Registered: 2020-07-13
Posts: 23

Re: IntelliJ IDEA won't recognize JDK

This may be a system-wide problem? Because I tried installing LibreOffice, and it says that it can't find the jdk either.

 
Warning: failed to read path from javaldx
LibreOffice 6.4 - Fatal Error: The application cannot be started. 
[context="user"] caught unexpected com.sun.star.ucb.ContentCreationException: Cannot create folder (invalid path): '$HOME'
 

I've installed JDK versions 8,11,14, and 15, but they all give me these kinds of problems for libreoffice and IntelliJ. Also, my $PATH includes /lib/jvm/default, /usr/lib/jvm/default, and /usr/lib/jvm/default/bin

Offline

#5 2020-10-17 23:39:41

solskog
Member
Registered: 2020-09-05
Posts: 246

Re: IntelliJ IDEA won't recognize JDK

I think this is on the IDEA project settings. IDEA-> File -> Project structure -> Project SDK
Try create a simple command line java project with this setting and see if you get same error.

Last edited by solskog (2020-10-18 01:48:23)

Offline

#6 2020-10-18 05:35:33

origamisith
Member
Registered: 2020-07-13
Posts: 23

Re: IntelliJ IDEA won't recognize JDK

I have already done so. Again, I have tried setting the Project SDK to several different versions of the JDK and different paths as well. My program was the simplest Hello World program.

Offline

#7 2020-10-18 08:00:49

solskog
Member
Registered: 2020-09-05
Posts: 246

Re: IntelliJ IDEA won't recognize JDK

How about check your java environment by compile and run a simple Hello World from terminal/urxvt/st/gnome-terminal command line outside IDEA?

$ source /etc/profile.d/jre.sh
$ echo $PATH
$ cat HelloWorld.java
public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello, World");
    }
}
$ javac HelloWorld.java
$ java HelloWorld
...

Or via IDEA Terminal.

$ cat IdeaProjects/HelloWorld/src/com/company/HelloWorld.java
package com.company;
public class Main {
    public static void main(String[] args) {
        System.out.println("Hello, World");
    }
$
$ source /etc/profile.d/jre.sh
$ echo $PATH
$ cd IdeaProjects/HelloWorld/src/
$ javac com/company/HelloWorld.java
$ java com/company/HelloWorld
...

What is the error message if any?

Last edited by solskog (2020-10-18 08:13:40)

Offline

#8 2020-10-18 08:44:01

origamisith
Member
Registered: 2020-07-13
Posts: 23

Re: IntelliJ IDEA won't recognize JDK

Oh yes, I forgot to mention. The JDK works when just called with java or javac.JShell works. Also, Eclipse doesn't have any problems.

Offline

#9 2020-10-18 10:06:11

solskog
Member
Registered: 2020-09-05
Posts: 246

Re: IntelliJ IDEA won't recognize JDK

Well then, this must be a IDEA environment issue.

Offline

#10 2020-10-18 16:30:50

twelveeighty
Member
From: Alberta, Canada
Registered: 2011-09-04
Posts: 686

Re: IntelliJ IDEA won't recognize JDK

origamisith wrote:

Oh yes, I forgot to mention.

Let's slow down here for a minute. I don't think you fully understand how [ extra ]'s jdk-openjdk, AUR versions, archlinux-java, JAVA_HOME and IDEA project settings work together. The very first question that @Lone_Wolf asked is actually the most relevant: *how* did you install openjdk 15? Even if you are now on JDK 14, we need to pause for a sec and get the full story there. That will likely get us to a place where your problem can be fixed.

Offline

#11 2020-10-23 06:15:43

origamisith
Member
Registered: 2020-07-13
Posts: 23

Re: IntelliJ IDEA won't recognize JDK

For openjdk 15: Went to the JDK website and downloaded the tarball from https://jdk.java.net/15/. Once I extracted, I moved it to /lib/jvm, and it appeared in the list of archlinux-java status.
For openjdk 14:

pacman -S jre-openjdk 

. Also tried jre11-openjdk and jre8-openjdk.
When I run

echo $JAVA_HOME

I see nothing, but I thought I didn't need to set that myself.

**Correction** The first time I tried installing openjdk 15 was by getting the "java-openjdk-bin" package from the AUR, with git clone and makepkg -rsi as usual.

Last edited by origamisith (2020-10-23 06:23:39)

Offline

#12 2020-10-23 08:06:03

solskog
Member
Registered: 2020-09-05
Posts: 246

Re: IntelliJ IDEA won't recognize JDK

you are suppose to install jdk not jre for java development.

# pacman -S jdk-openjdk

Offline

Board footer

Powered by FluxBB