48

I am a new user of Linux, it has been recommended to me by my friend.

He told me to install software called IntelliJ Idea IDE.

Well I have been following the tutorial. But now when I try to open "idea.sh", an error message pops-up:

'tools.jar' is not in IDEA classpath.
Please ensure JAVA_HOME points to JDK rather than JRE.

Please remember that I'm new to Ubuntu and I'm planning for a nice long stay once I get myself into it :)

Also I do not know if I am running a correct Java6 JDK. When I do java -version, this is what I get:

java version "1.6.0_23"
OpenJDK Runtime Environment (IcedTea6 1.11pre) (6b23~pre10-0ubuntu5)
OpenJDK 64-Bit Server VM (build 20.0-b11, mixed mode)

Thank You for reading this and I hope I will get a nice response.

1

9 Answers 9

62

Be sure you have a JDK installed on your system.

sudo apt-get install openjdk-7-jdk

If that does not solve your problem, you must tell your system to use that JDK instead of the current JRE. To do so, you choose which JDK/JRE you use by default on your system by executing the following command in terminal.

sudo update-alternatives --config java

This command will give you a list of alternative java options, which you will then be able select a JDK instead of JRE.

7
  • this helped a lot but now I'm getting: tools.jar' seems to be not in IDEA classpath. Please ensure JAVA_HOME points to JDK rather than JRE. Mar 21, 2014 at 21:33
  • @advocate I saw your comment on SO; you issue has been resolved by reinstalling JDK, correct?
    – allejo
    Mar 22, 2014 at 1:10
  • 2
    yup! just sudo apt-get install openjdk-7-jdk Mar 23, 2014 at 18:32
  • 2
    I had to set the JAVA_HOME path in ~/.bashrc before this worked. Oct 3, 2014 at 14:25
  • Could you tell me how can i do this, "set the JAVA_HOME .... " Dec 8, 2014 at 8:28
15

On my Linux Mint environment I've encountered the same problem. I tried to install Oracle JDK8 using

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer

but the problem remained because installer didn't change environment variables. Then I tried the following

sudo apt-get install oracle-java8-set-default

and it solved the problem

2
  • Perfect solution for me and also allowed Java 8 use
    – Pitto
    May 5, 2015 at 12:45
  • this worked for me (elementary OS x64 Freya) thanks
    – zguell
    Oct 2, 2015 at 20:33
5

Try this command

export JAVA_HOME=/usr/lib/jvm/default-java

and run idea.sh again.

Mind you, this only works inside the terminal where you run the command. You will have to set the variable inside .bashrc file. This will enable it on every terminal you open.

StackOverFlow

2
  • i tried this but still got the same error Dec 8, 2014 at 8:31
  • Thank you! I know this isn't everyone's problem, but none of the other answers actually say what I should set JAVA_HOME to!
    – River Tam
    Aug 9, 2015 at 17:43
5

Try this:

sudo apt-get install openjdk-6-jdk

You need JDK.

5

The answers above are correct but I have one thing to add. Actually the environment variables for Shell Session and Desktop GUI Session are different (check this). If the error happens when you launch IntelliJ with Desktop Entry(the Launcher), you might don't have JAVA_HOME in your GUI Environment.

So the easiest solution is to add JAVA_HOME in the Exec line of the desktop entry like this:

[Desktop Entry]
Version=1.0
Type=Application
Name=IntelliJ IDEA Community Edition
Icon=/home/zhu/Applications/IntelliJ/bin/idea.png
Exec=env JDK_HOME=/usr/lib/jvm/java-7-openjdk-amd64 "/path/to/idea.sh" %f
Comment=Develop with pleasure!
Categories=Development;IDE;
Terminal=false
StartupWMClass=jetbrains-idea-ce
1
  • Perfect solution for my issue. Adding the env argument in the Exec did the trick. Nov 29, 2016 at 0:16
2

I've solved this problem with these commands

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer
sudo apt-get install oracle-java8-set-default

and

export JAVA_HOME=/usr/lib/jvm/default-java
1
  • Where do you place the last command export JAVA_HOME=/usr/lib/jvm/default-java you mention?
    – MadMike
    Mar 4, 2015 at 6:50
1

The solution of exporting the JAVA_HOME variable doesn't work for me in Ubuntu. I solved it adding the bin directory to the PATH variable.

I downloaded the JDK from the Oracle website, and I placed it in this directory: /home/alejandro/software/JAVA-descarga/jdk1.8.0_25

Then you have to add that route to the PATH variable:

export PATH=/home/alejandro/software/JAVA-descarga/jdk1.8.0_25/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games  

Then run the idea.sh file in the same terminal and it will start well.

0

edit the file android-studio/bin/studio.sh

like the mark content(JAVA_HOME line)

#!/bin/sh
#
# ---------------------------------------------------------------------
# Android Studio startup script.
# ---------------------------------------------------------------------

    JAVA_HOME=your_path/jdk1.8.0_31

message()
0

Even though on UI popup message it says

'tools.jar' is not in IDEA classpath.
Please ensure JAVA_HOME points to JDK rather than JRE.

on command line it shows

ERROR: cannot start IntelliJ IDEA.
No JDK found to run IDEA. Please validate either IDEA_JDK or JDK_HOME points to valid JDK installation

and this was exactly the issue for me. Setting JAVA_HOME did not work but had to set JDK_HOME to make it work.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .