I have a java computer program that I can compile in Eclipse just fine. I want to compile it from the command line and get the message javac not found. I figured that I just didn't have my path setup right, but then I did a locate javac and I only get:


and it does not exist in


In Eclipse, it looks like it is using this JDK, so I am not sure how to account for how Eclipse compiles. Am I missing something silly? Thanks.

  • 1
    what is the output of 'javac -version' in the terminal? – ganezdragon May 24 '14 at 7:54
  • That is just the problem - it can't find the command. But Eclipse must be using it somewhere, right? – skaz May 24 '14 at 11:11
  • 1
    I think Eclipse comes with a inbuilt compiler... so you might want to install jdk manually to run Java programs using the terminal. – ganezdragon May 24 '14 at 11:21
  • Try sudo apt-get install openjdk-7-jdk. – saiarcot895 May 24 '14 at 13:30

The default Java runtime environment (JRE) on Ubuntu is OpenJDK (instead of Oracle/Sun). Unlike the name OpenJDK this comes as two parts: a JRE (default-jre) and a JDK (default-jdk).

To also install the JDK (providing javac), install the metapackage default-jdk Install default-jdk and you should be all set.

In case you have more than one Java runtime or Java compiler installed, select the right one with update-alternatives:

sudo update-alternatives --config java   # runtime
sudo update-alternatives --config javaws # runtime Web Start (applets)
sudo update-alternatives --config javac  # compiler

It seems like the openjdk you are using isn`t a jdk(besides the name). It is just a jvm (it can run java programs but not compile them).

My solution was download the jdk from oracle site: http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html

(this link is for jdk7, if you need another version just look for jdk in the site).


It looks like my default install came with some weird version of Java - not the OpenJDK but even another version. I did an aptitude install to get the openjdk-7 and then everything worked fine.

I was confused because Eclipse compiled without a javac on the system, but I guess Eclipse has some tools inside that allow it to compile.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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