如何更正应该指向 JDK 而不是 JRE 文件夹的 JAVA_HOME?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23619545/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to correct JAVA_HOME which should point to a JDK not a JRE folder?
提问by Mr Mikkél
I'm trying to run Catalina on Ubuntu Linux using the debug command. I'm getting the following error:
我正在尝试使用 debug 命令在 Ubuntu Linux 上运行 Catalina。我收到以下错误:
JAVA_HOME should point to a JDK in order to run in debug mode.
/bin/sh died with exit status 1
However, I have tried setting JAVA_HOME in the .bashrc
to all of the following:
但是,我尝试将 JAVA_HOME 设置.bashrc
为以下所有内容:
export JAVA_HOME="/usr/lib/jvm/java-1.7.0-openjdk-i386/"
export JAVA_HOME="/usr/lib/jvm/java-1.7.0-openjdk-i386"
export JAVA_HOME="/usr/lib/jvm/java-1.7.0-openjdk-i386/jre/bin"
export JAVA_HOME="/usr/lib/jvm/java-1.7.0-openjdk-i386/jre/bin/"
Am I missing anything?
我错过了什么吗?
回答by vkg
Method 1Adding to bashrc will work.
方法 1添加到 bashrc 将起作用。
Method 2But I think a better way is to add it to catalina.sh
方法2但我觉得更好的方法是将其添加到catalina.sh
JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-i386/jre/bin
Method 3And even a more cleaner way would be create a env_var.sh (assuming you created env_var.sh in same folder as catalina.h) file and then use the env_var.sh file in catalina.sh like this
方法 3甚至更简洁的方法是创建一个 env_var.sh(假设您在与 catalina.h 相同的文件夹中创建了 env_var.sh)文件,然后像这样在 catalina.sh 中使用 env_var.sh 文件
source ./env_var.sh
Now you can throw your own environment specific settings in this new file and leave catalina.sh at peace. Advantage is you are not messing up catalina.sh and you not dependent on one particular users bash profile.
现在你可以在这个新文件中加入你自己的环境特定设置,让 catalina.sh 保持平静。优点是您不会弄乱 catalina.sh 并且您不依赖于一个特定用户的 bash 配置文件。
Simple Example of env_var.sh
env_var.sh 的简单示例
#!/bin/sh
JAVA_OPTS="$JAVA_OPTS -server"
JAVA_OPTS="$JAVA_OPTS -Xms2096m"
JAVA_OPTS="$JAVA_OPTS -Xmx4096m"
JAVA_OPTS="$JAVA_OPTS -XX:PermSize=128m"
JAVA_OPTS="$JAVA_OPTS -XX:MaxPermSize=512m"
echo Using JAVA_OPTS settings $JAVA_OPTS
CATALINA_OPTS="$CATALINA_OPTS -Dcom.sun.management.jmxremote"
CATALINA_OPTS="$CATALINA_OPTS -Dcom.sun.management.jmxremote.port=[some_port]"
echo Using CATALINA_OPTS settings $CATALINA_OPTS
JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-i386
I hope it helps :)
我希望它有帮助:)
回答by kenorb
In Debian/Ubuntu run:
在 Debian/Ubuntu 中运行:
$ sudo update-alternatives --config java
Path
---------------------------------------------
/usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java
/usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java
/usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java
to find out your JREjava paths, so your JDKpath is the one without jre
, for example:
找出你的JREjava 路径,所以你的JDK路径是没有的jre
,例如:
JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
So you can either export
this variable or prefix before running the command, e.g.:
所以你可以export
在运行命令之前使用这个变量或前缀,例如:
JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64 catalina.sh debug