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

Mr Mikkél picture Mr Mikkél · May 12, 2014 · Viewed 18.6k times · Source

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?

Answer

kenorb picture kenorb · Apr 9, 2015

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 the executables that are linked with your java command.

Note: when update-alternatives is used with the --config option, the expected goal is to manually set the executable linked with the command (for e.g., see here). For our purposes, we could use --query option instead.

The JDK paths are the prefix in these paths, i.e., the one before jre. For example, based on the above output, you could set JAVA_HOME in your .bashrc file:

export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
export PATH=$JAVA_HOME/bin:$PATH

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

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