简体   繁体   中英

javac gives an error message , that it has been found

When I type java -version the following is returned :

java version "1.6.0_24"
OpenJDK Runtime Environment (IcedTea6 1.11.1) (6b24-1.11.1-4ubuntu2)
OpenJDK Server VM (build 20.0-b12, mixed mode)

but when I type javac -version I get the following message :

The program 'javac' can be found in the following packages:
* openjdk-6-jdk
* ecj
* gcj-4.4-jdk
* gcj-4.6-jdk
* gcj-4.5-jdk
* openjdk-7-jdk
Try: sudo apt-get install <selected package>

Why is this ? What do I need to do to get rid of this ?

You have installed the java runtime environment (jre) which contains stuff to execute java programs, but not the java development kit (jdk) which contains stuff to build such applications, like the compiler. So install one of these packages, as the message tells you, eg

sudo apt-get install openjdk-7-jdk

The java command executes a program that is already compiled to a .class file (Java bytecode), it's just the runtime environment.

javac is the Java compiler. It turns Java source code into Java bytecode (.class files).

The two are separate programs because a typical user only needs the runtime ( java ) but not javac .

You need to install one of the listed packages (preferably openjdk-6-jdk. since it will be compatible with your java installation).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM