Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am new to Ubuntu and am trying to set up Java to run and compile programs. As I am very fresh, I am not sure how to tell which version I am using but file /sbin/init returns:

    ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=0x7aa29ded613e503fb09fb75d94026f3256f01e7a, stripped

The problem I have is when it comes to running the Java programs. Although the programs compile they don't seem to run. I used this guide:

And everything seems fine until I go to run the program I get this error message:

    bash: /usr/bin/java: No such file or directory

Java is supposed to be run from /usr/local/java and the /etc/profile has:

    export JAVA_HOME
    export JRE_HOME
    export PATH

I'm sure I'm missing something really simple. Thanks in advance.

share|improve this question
up vote 0 down vote accepted

After recently installing Oracle Java following the same instructions, I ran into a similar error. The link to the java executable appears to be missing in your /usr/bin. To resolve this, I would manually create the link:

$ sudo ln -s /etc/alternatives/java /usr/bin/java

You may have to change /etc/alternatives/java to point to the correct location, but this is the default based on the instructions you followed.

share|improve this answer

sudo ln -s /usr/lib/jvm/java-7-openjdk/bin/javac /usr/bin/javac

That line of code fixed the problem for me, replace java-7-openjdk with java 6 if you are not running 7.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.