简体   繁体   English

javac给出一条错误消息,表明已找到

[英]javac gives an error message , that it has been found

When I type java -version the following is returned : 当我输入java -version ,返回以下内容:

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 : 但是当我键入javac -version ,会收到以下消息:

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. 您已经安装了Java运行时环境(jre),其中包含用于执行 Java程序的内容,但尚未安装Java开发工具包(jdk),其包含用于构建此类应用程序(如编译器)的内容。 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. java命令执行一个已经编译为.class文件(Java字节码)的程序,它只是运行时环境。

javac is the Java compiler. javac是Java编译器。 It turns Java source code into Java bytecode (.class files). 它将Java源代码转换为Java字节码(.class文件)。

The two are separate programs because a typical user only needs the runtime ( java ) but not javac . 这两个程序是分开的程序,因为典型的用户只需要运行时( java ),而不需要javac

You need to install one of the listed packages (preferably openjdk-6-jdk. since it will be compatible with your java installation). 您需要安装列出的软件包之一(最好是openjdk-6-jdk。因为它将与您的Java安装兼容)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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