2

I'm trying to run IntelliJ on Ubuntu 14.04. I've read this question but the solutions don't apply -- I've definitely got the JDK installed rather than the JRE. When I try to run idea.sh, I get the error message:

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

JAVA_HOME is set to /etc/java-7-openjdk. Eclipse (in the form of Eclim) has no problem finding it. javac -version prints javac 1.7.0_55.

However, if I run sudo ./idea.sh, IntellJ launches fine. What am I missing?

Community
  • 1
  • 1
Patrick Collins
  • 10,306
  • 5
  • 30
  • 69

4 Answers4

5

I had the exact same problem half an hour ago. Took me exactly that half hour to fix it, this is how it worked for me:

Short version: add

export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64

to your .bashrc, source it and you are fine.

Explanation:

After installing the JDK in Ubuntu there are multiple folders on your disk. The root folder is

/usr/lib/jvm/java-7-openjdk-amd64/

under which the aforementioned /jre -Folder resides. The whole problem is, that the jre/lib -Folder does not contain the tools.jar - File searched by the IDE. Only the /usr/lib/jvm/java-7-openjdk-amd64/lib - Folder does.

To get everything working you have to specify /usr/lib/jvm/java-7-openjdk-amd64 as JAVA_HOME.

Setting /usr as your JAVA_HOME wont solve the problem as that is symlinked to /etc/alternatives which is symlinked to our old friend the /jre-Folder.

I hope this helped you!

joe
  • 51
  • 1
  • 3
3

In the 64 bit Debian 7, I solved the problem by adding this two lines of code in idea.sh under the /path/to/intellij-folder/bin/

export IDEA_JDK=/path/to/jdk/
export JAVA_HOME=/path/to/jre

And I hope it will solve the problem in Ubuntu.

Esmaeil MIRZAEE
  • 1,110
  • 11
  • 14
1

It turns out JAVA_HOME was set wrong, I needed to set it to:

/usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java

to get it working. I'm not sure why this hadn't caused me any problems before.

EDIT: This setting makes Maven angry (although Maven via IntelliJ works fine). For future readers, I believe the correct setting is:

export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64/jre/
Patrick Collins
  • 10,306
  • 5
  • 30
  • 69
0

you can change your current java version as follows

alternatives --config java 
alternatives --config javac

but before them you need to install your newly installed JDK in alternatives properly:

alternatives --install /usr/bin/java java [new-jdk-path]/bin/java 120 --slave /usr/bin/rmiregistry rmiregistery [new-jdk-path]/bin/rmiregistry --slave /usr/bin/keytool keytool [new-jdk-path]/bin/keytool --slave /usr/lib/tools.jar tools.jar [new-jdk-path]/lib/tools.jar

alternatives --install /usr/bin/javac javac [new-jdk-path]/bin/javac 120 --slave /usr/bin/jar jar [new-jdk-path]/bin/jar --slave /usr/bin/rmic rmic [new-jdk-path]/bin/rmic 
Jamali
  • 754
  • 10
  • 24