Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Having trouble with setting JAVA_HOME on ubuntu linux

843789Jun 6 2009 — edited Jun 7 2009
**Sorry, I guess I have posted in the wrong forums, there's a specific forum for the Java compiler - if any mod can move my topic I'd be grateful**

Hello.

I am encountering a problem while setting a JAVA_HOME environment variable on my ubuntu linux 9.04
I will write down things I've done step by step:

prequisites
sudo apt-get install sun-java6-jdk
sudo apt-get install ant
Then I have tried adding JAVA_HOME variable in these places:
# in /home/nyash/.bashrc
# in /etc/profile
# in /etc/environment
# in /etc/bash.bashrc
export JAVA_HOME=/usr/lib/jvm/java-6-sun
export PATH=$JAVA_HOME/bin:$PATH
But no matter where it was added to I was getting this error while trying to compile:
nyash@ubuntu:/usr/local/OpenGTS$ sudo ant all
Unable to locate tools.jar. Expected to find it in /usr/lib/jvm/java-6-openjdk/lib/tools.jar
Buildfile: build.xml

clean:
   [delete] Deleting directory /usr/local/OpenGTS/build

custom:
     [echo] Skipping Custom build ...

prepare:
    [mkdir] Created dir: /usr/local/OpenGTS/build
    [mkdir] Created dir: /usr/local/OpenGTS/build/lib
     [exec] java version "1.6.0_0"
     [exec] OpenJDK Runtime Environment (IcedTea6 1.4.1) (6b14-1.4.1-0ubuntu7)
     [exec] OpenJDK Client VM (build 14.0-b08, mixed mode, sharing)
     [copy] Copying 2 files to /usr/local/OpenGTS/build/lib

gtsutils:
     [echo] Creating gtsutils.jar ...
     [echo] ---------------------------------------------------------------------------
     [echo] Note: Ignore any "sun.reflect.Reflection" warnings that may be displayed
     [echo] ---------------------------------------------------------------------------
    [javac] Compiling 43 source files to /usr/local/OpenGTS/build

BUILD FAILED
/usr/local/OpenGTS/build.xml:323: Unable to find a javac compiler;
com.sun.tools.javac.Main is not on the classpath.
Perhaps JAVA_HOME does not point to the JDK.
It is currently set to "/usr/lib/jvm/java-6-openjdk/jre"
Everytime I check $JAVA_HOME it's set to the correct location:
nyash@ubuntu:~$ echo $JAVA_HOME
/usr/lib/jvm/java-6-sun
However the error output says it's set to */usr/lib/jvm/java-6-openjdk/jre* (the one I am not intending to have)

I have absolutely no idea what to do, I browsed literally the entire web and I cant find a definitive
solution to this.

I would greatly appreciate help!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 5 2009
Added on Jun 6 2009
2 comments
441 views