setting the JAVA_HOME environment variable

Derek Broughton news at pointerstop.ca
Mon Mar 24 13:27:48 UTC 2008


James Gray wrote:

> 
> On 24/03/2008, at 7:35 PM, Thufir wrote:
> ---8<---  SNIPPED ---8<---
>> extconf.rb:33: JAVA_HOME is not directory. (RuntimeError)
>> thufir at arrakis:~$
>> thufir at arrakis:~$ echo $JAVA_HOME
>> /usr/lib/jvm/java-6-sun/jre/bin/java
> 
> The error message is correct - JAVA_HOME is a directory, not the Java
> binary.  In your case it appears you need to replace your existing
> JAVA_HOME with:
> $ export JAVA_HOME=/usr/lib/jvm/java-6-sun/jre
> 

And in answer to Thufir's original question, you'd put it in /etc/profile,
but...

> In short the JAVA_HOME variable should be the *directory* that
> contains the "bin" directory that holds your preferred java binary.
> IOW "/usr/lib/jvm/java-6-sun/jre" (ie, JAVA_HOME) holds "bin/" which
> holds your preferred "java" binary, so when you string it together you
> end up with (mathematically):
> /usr/lib/jvm/java-6-sun/jre + bin/ + java = /usr/lib/jvm/java-6-sun/
> jre/bin/java

In my experience, JAVA_HOME should _never_ need to be set, if java is
properly installed.  Anything that won't work without JAVA_HOME needs to be
fixed itself.

Use update-java-alternatives to make sure that everything properly symlinks
to the correct directories, then JAVA_HOME should be automatically derived
from directory containing the java executable.  I do a lot of Java, and I
never set JAVA_HOME.  (Eclipse was noticeably wrong and used to require
JAVA_HOME, but iirc it's fixed now)
-- 
derek





More information about the ubuntu-users mailing list