Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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: http://www.wikihow.com/Install-Oracle-Java-on-Ubuntu-Linux

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:

    JAVA_HOME=/usr/local/java/jdk1.7.0_45
    PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
    JRE_HOME=/usr/local/java/jre1.7.0_45
    PATH=$PATH:$HOME/bin:$JRE_HOME/bin
    export JAVA_HOME
    export JRE_HOME
    export PATH

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

share|improve this question

2 Answers 2

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

 
discard

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.