Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

javac does not work in ubuntu terminal

Tags:

java

javac

ubuntu

When I try to compile a java program with javac, I get an error:

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 <selected package 

When I try java -version, it says,

java version "1.7.0_21" OpenJDK Runtime Environment (IcedTea 2.3.9) (7u21-2.3.9-1ubuntu1) OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode) 

When I try which java I get /usr/bin/java

How do I compile my java program from commandline?

like image 823
Prasanna Avatar asked Apr 28 '13 21:04

Prasanna


1 Answers

As mentioned by @Blorgbeard you most likely do not have a Java JDK (Java Development Kit) installed. See this web page for more information about the various versions of Java available for Ubuntu.

The following command will install the OpenJDK version of the Java JDK:

apt-get install default-jdk 
like image 160
HeatfanJohn Avatar answered Sep 21 '22 10:09

HeatfanJohn