In Windows, JAVA_HOME
must point to the JDK installation folder (so that JAVA_HOME/bin
contains all executables and JAVA_HOME/libs
contains all default jar
libraries).
If I download Sun's JDK bundle and installs it in Linux, it is the same procedure.
However, I need to use Kubuntu's default OpenJDK package. The problem is that all executables are placed in /usr/bin
. But the jars are placed in /usr/share/java
. Since they are not under the same JAVA_HOME
folder I'm having trouble with Grails and maybe there will be trouble with other applications that expect the standard Java structure.
If I use:
JAVA_HOME=/usr
All applications and scripts that want to use any Java executable can use the standard procedure call $JAVA_HOME/bin/executable
. However, since the jars are in a different place, they are not always found (example: in grails I'm getting ClassDefNotFound
for native2ascii
).
On the other hand, if I use:
JAVA_HOME=/usr/share/java
None of the Java executables (java
, javac
, etc.) can be found.
So, what is the correct way of handling the JAVA_HOME
variable in a Debian-based Linux?
Thanks for your help, Luis
In Windows, JAVA_HOME must point to the JDK installation folder (so that JAVA_HOME/bin contains all executables and JAVA_HOME/libs contains all default jar libraries). If I download Sun's JDK bundle and installs it in Linux, it is the same procedure.
2) JAVA_HOME variable is short and concise instead of full path to JDK installation directory. 3) JAVA_HOME variable is platform independence i.e. if your startup script uses JAVA_HOME then it can run on Windows and UNIX without any modification, you just need to set JAVA_HOME on respective operating system.
Set JAVA_HOME: Right click My Computer and select Properties. On the Advanced tab, select Environment Variables, and then edit JAVA_HOME to point to where the JDK software is located, for example, C:\Program Files\Java\jdk1. 6.0_02.
JAVA_HOME is an operating system (OS) environment variable which can optionally be set after either the Java Development Kit (JDK) or the Java Runtime Environment (JRE) is installed. The JAVA_HOME environment variable points to the file system location where the JDK or JRE was installed.
What finally worked for me (Grails now works smoothly) is doing almost like Steve B. has pointed out:
JAVA_HOME=/usr/lib/jvm/default-java
This way if the user changes the default JDK for the system, JAVA_HOME
still works.
default-java
is a symlink to the current JVM.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With