Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.
sachin@sachin-Lenovo-G550:~$ java -version
java version “1.7.0_21″
OpenJDK Runtime Environment (IcedTea 2.3.9) (7u21-2.3.9-1ubuntu1)
OpenJDK Server VM (build 23.7-b01, mixed mode)

When I ran the above command this showed that Java is installed in my system, but when I am going to compile any Java program it gives the following error message:

sachin@sachin-Lenovo-G550:~/programs$ javac abc.java
The program ‘javac’ can be found in the following packages:
* default-jdk
* ecj
* gcj-4.6-jdk
* gcj-4.7-jdk
* openjdk-7-jdk
* openjdk-6-jdk
Try: sudo apt-get install

Please tell me how to get rid of it and run my Java program.

share|improve this question

1 Answer 1

Open the terminal and run:

sudo apt-get install openjdk-7-jdk

and then compile your Java program as before with: javac abc.java. Then run it with:

java abc  ## The name of the class to be called is abc NOT abc.class

You can also substitute openjdk-6-jdk instead of openjdk-7-jdk in the first command.

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.