Setting JAVA_HOME on Ubuntu 10.x
Solution 1
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
Solution 2
Since you're on Ubuntu, and it seems that you are using the default packages of Sun's Java for the OS, you should probably use the `update-alternatives' command. As you can see, I have 2 JVM's installed, but the Sun version is the one that gets used by default.
root@workstation:~# update-alternatives --query java
Link: java
Status: manual
Best: /usr/lib/jvm/java-6-openjdk/jre/bin/java
Value: /usr/lib/jvm/java-6-sun/jre/bin/java
Alternative: /usr/lib/jvm/java-6-openjdk/jre/bin/java
Priority: 1061
Slaves:
java.1.gz /usr/lib/jvm/java-6-openjdk/jre/man/man1/java.1.gz
Alternative: /usr/lib/jvm/java-6-sun/jre/bin/java
Priority: 63
Slaves:
java.1.gz /usr/lib/jvm/java-6-sun/jre/man/man1/java.1.gz
If you only have one, you don't have to worry about it. If you have more than one, and need to set it, you can use the Java-specific version of the command, `update-java-alternatives'. It's all here:
https://help.ubuntu.com/community/Java
Related videos on Youtube
kocakmstf
Updated on September 17, 2022Comments
-
kocakmstf over 1 year
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?
-
Naftuli Kay over 13 yearsrun
echo $JAVA_HOME
in a terminal. What does that give you? Also, lose the "export" statement, should be unnecessary and might be what's giving you the problem. -
kocakmstf over 13 yearsusername@ubuntu:~$ echo $JAVA_HOME /usr/lib/jvm/java-6-sun/jre/bin/java
-
-
kocakmstf over 13 yearsusername@ubuntu:~$ echo $JAVA_HOME /usr/lib/jvm/java-6-sun/jre/bin/java
-
Naftuli Kay over 13 yearsDid you edit your .bashrc file? Did it work?
-
Naftuli Kay over 13 yearsTry new above edits.
-
kocakmstf over 13 yearsSame problem. I think the issue is tied to my java installation. Should I delete everything from my jvm folder, then start from scratch?
-
Naftuli Kay over 13 yearsHow did you install Java? And you're using Sun JDK? If so, why? You should wipe your Java install if you're using Sun/Oracle/Corporate/Whatever JVM, then run
sudo apt-get install openjdk-6-jdk
. -
kocakmstf over 13 yearsWhy should I use the openjdk as opposed to sun?
-
Naftuli Kay over 13 yearsBetter support, easier install. I've never had any problems or real differences in using OpenJDK and Sun, in fact I've heard that OpenJDK performs better as a server than the Sun JVM.
-
David Krider about 13 yearsAnd, now that I think about it, shouldn't this go to the "Ask Ubuntu" StackExchange site?