IntelliJ can't find tools.jar without sudo
Solution 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/
Solution 2
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!
Solution 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.
Patrick Collins
Updated on June 04, 2022Comments
-
Patrick Collins almost 2 years
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
printsjavac 1.7.0_55
.However, if I run
sudo ./idea.sh
, IntellJ launches fine. What am I missing? -
Nishant Kelkar over 9 yearsThanks! This was exactly the issue I was facing and your solution/explanation helped me resolve it!
-
Melroy van den Berg over 7 yearsYou know that "export" is not needed in
.bashrc
file? Thus can be removed.