5

I'm trying to setup an SDK for intellij idea and I can't find the home for jdk as the error put it.

In the terminal this is what I get

$ java -version
openjdk version "9-internal"
OpenJDK Runtime Environment (build 9-internal+0-2016-04-14-195246.buildd.src)
OpenJDK 64-Bit Server VM (build 9-internal+0-2016-04-14-195246.buildd.src, mixed mode)

I tried to run

$ whereis java

and none of the paths are valid

then I found the jvm folder in usr/lib/jvm none of those worked either.

this is the output of

$ ls -lh /usr/lib/jvm/

enter image description here

I just ran another command

$ update-alternatives --list java

Output was

/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java
/usr/lib/jvm/java-9-openjdk-amd64/bin/java

In idea, the sdk selector will only go upto the /bin but the internal files don't appear and in the file explorer I can see the java file but clicking it does nothing nor can I directly copy it's path as I get the error:

"Specified path cannot be found"

Also ran

$ sudo update-alternatives --display java

Output

java - auto mode
link best version is /usr/lib/jvm/java-9-openjdk-amd64/bin/java
link currently points to /usr/lib/jvm/java-9-openjdk-amd64/bin/java
link java is /usr/bin/java
slave java.1.gz is /usr/share/man/man1/java.1.gz
/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java - priority 1081
slave java.1.gz: /usr/lib/jvm/java-8-openjdk-amd64/jre/man/man1/java.1.gz
/usr/lib/jvm/java-9-openjdk-amd64/bin/java - priority 1091
slave java.1.gz: /usr/lib/jvm/java-9-openjdk-amd64/man/man1/java.1.gz

3 Answers3

1

You will need to add JAVA_HOME to your .bashrc file.

  1. Edit the:

    gedit ~/.bashrc
    
  2. Add the following lines:

    ## JAVA_HOME
    export JAVA_HOME="/usr/lib/jvm/java-9-openjdk-amd64"
    export PATH=$PATH:$JAVA_HOME/bin
    
  3. Add it to the /etc/environemnt file with:

    echo "JAVA_HOME=\"/usr/lib/jvm/java-9-openjdk-amd64\"" | sudo tee -a /etc/environment
    
  4. Close and open a new terminal.

  5. If all doesn't work then:

    1. Launch Intellij

    2. Press: ctrl+alt+shift+S

      • The go to Platform Settings -> SDKs
      • click to add the path for your java sdk

      enter image description here

Now your IntelliJ should be able to see it.

George Udosen
  • 37,534
0

I had the same error because I had changed my jdk and my Intellij was still referring to the location where I had my previous jdk. All I did was go to File -> Project Structure. Go to SDKs under Platform Settings in the project structure dialog box. After this, you just navigate to the place where you have installed the jdk home directory. (For me, it was /usr/local/jdk1.8.0_271). And just do Apply then Ok. This error should go away.

0

I had the same error, becauese I changed the folder(directory) for download. I solved it, go to 'File -> Project Structure' and 'Project Settings -> Project', SDK : "download folder -> jbr". That's all I did.

Austin
  • 1