[英]IntelliJ can't find tools.jar without sudo
I'm trying to run IntelliJ on Ubuntu 14.04. 我正在尝试在Ubuntu 14.04上运行IntelliJ。 I've read this question but the solutions don't apply -- I've definitely got the JDK installed rather than the JRE.
我已经阅读了这个问题,但解决方案并不适用 - 我肯定安装了JDK而不是JRE。 When I try to run
idea.sh
, I get the error message: 当我尝试运行
idea.sh
,我收到错误消息:
'tools.jar' seems to be not in IDEA classpath.
'tools.jar'似乎不在IDEA类路径中。 Please ensure JAVA_HOME points to JDK rather than JRE.
请确保JAVA_HOME指向JDK而不是JRE。
JAVA_HOME
is set to /etc/java-7-openjdk
. JAVA_HOME
设置为/etc/java-7-openjdk
。 Eclipse (in the form of Eclim) has no problem finding it. Eclipse(以Eclim的形式)找到它没有问题。
javac -version
prints javac 1.7.0_55
. javac -version
打印javac 1.7.0_55
。
However, if I run sudo ./idea.sh
, IntellJ launches fine. 但是,如果我运行
sudo ./idea.sh
正常运行。 What am I missing? 我错过了什么?
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. 来你的
.bashrc
,来源它,你很好。
Explanation: 说明:
After installing the JDK in Ubuntu there are multiple folders on your disk. 在Ubuntu中安装JDK后,磁盘上有多个文件夹。 The root folder is
根文件夹是
/usr/lib/jvm/java-7-openjdk-amd64/
under which the aforementioned /jre
-Folder resides. 上述
/jre
-Folder所在的位置。 The whole problem is, that the jre/lib
-Folder does not contain the tools.jar
- File searched by the IDE. 整个问题是,
jre/lib
-Folder不包含tools.jar
- IDE搜索的文件。 Only the /usr/lib/jvm/java-7-openjdk-amd64/lib
- Folder does. 只有
/usr/lib/jvm/java-7-openjdk-amd64/lib
- 文件夹可以。
To get everything working you have to specify /usr/lib/jvm/java-7-openjdk-amd64
as JAVA_HOME
. 要使一切正常,您必须将
/usr/lib/jvm/java-7-openjdk-amd64
为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. 设置
/usr
作为你的JAVA_HOME
不会解决问题,因为它与符号链接到/etc/alternatives
符号链接到我们的老朋友/jre
-Folder。
I hope this helped you! 我希望这对你有所帮助!
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/ 在64位Debian 7中,我通过在/ path / to / intellij-folder / bin /下的idea.sh中添加这两行代码解决了这个问题。
export IDEA_JDK=/path/to/jdk/
export JAVA_HOME=/path/to/jre
And I hope it will solve the problem in Ubuntu. 我希望它能解决Ubuntu中的问题。
It turns out JAVA_HOME
was set wrong, I needed to set it to: 事实证明
JAVA_HOME
设置错误,我需要将其设置为:
/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). 编辑:这个设置让Maven生气(虽然Maven通过IntelliJ工作正常)。 For future readers, I believe the correct setting is:
对于未来的读者,我认为正确的设置是:
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64/jre/
you can change your current java version as follows 您可以按如下方式更改当前的Java版本
alternatives --config java
alternatives --config javac
but before them you need to install your newly installed JDK in alternatives properly: 但在它们之前,您需要在备选方案中正确安装新安装的JDK:
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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.