How to correct JAVA_HOME which should point to a JDK not a JRE folder? [duplicate]

我们两清 提交于 2019-12-10 18:33:25

问题


I'm trying to run Catalina on Ubuntu Linux using the debug command. I'm getting the following error:

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:

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?


回答1:


In Debian/Ubuntu run:

$ 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 JRE java paths, so your JDK path is the one without jre, for example:

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

So you can either export this variable or prefix before running the command, e.g.:

JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64 catalina.sh debug



回答2:


Method 1 Adding to bashrc will work.

Method 2 But I think a better way is to add it to catalina.sh

JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-i386/jre/bin

Method 3 And 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

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.

Simple Example of 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 :)



来源:https://stackoverflow.com/questions/23619545/how-to-correct-java-home-which-should-point-to-a-jdk-not-a-jre-folder

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!