Ubuntu – Setting JAVA_HOME on Ubuntu 10.x

javapathUbuntu

I'm trying to get the Rhodes framework installed so I can develop Android apps.

This requires that I install the SUN JDK and add JAVA_HOME and JAVA_HOME/bin to path.

I thought I could solve this by editing my bash.bashrc file:

JAVA_HOME="/usr/lib/jvm/java-6-sun/jre/bin/java"
export JAVA_HOME
PATH=$PATH:$JAVA_HOME/bin

This still doesn't work, because when I run:

rake run:android

I get a prompt in the console that says the Java bin was not found in my path.

However, running echo $PATH gets me:

usernamee@ubuntu:~$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/home/username/ruby/gems/bin:/usr/lib/jvm/java-6-sun/jre/bin/java/bin:/home/username/ruby_files/android-sdk-linux_86/tools

What are my options here?

Edit: If the problem is not the export statement, how can I ensure that the Sun JDK is properly installed and that I am, in fact, pointing to the correct path in bashrc?

Best Answer

Try removing the export statement:

JAVA_HOME = /path/to/java
PATH = $PATH:$JAVA_HOME/bin

Then echo $JAVA_HOME in a new terminal to make sure you've got things exported correctly.

echo $JAVA_HOME

Alternatively, try this:

export JAVA_HOME=/path/to/java
export PATH=$PATH:$JAVA_HOME/bin