问题
I have a problem involving setting up Java.
I have installed the JRE, added its path to PATH
, and set JAVA_HOME
and CLASSPATH
. Now, java
and javacpl
work fine, but running javac
generates a command-not-found error. Furthermore, javac.exe
does not even seem to exist in the JRE's bin
folder.
How do I run javac
?
回答1:
The JRE is merely the Java Runtime Environment, which includes only the infrastructure needed to run Java programs that are already compiled.
To compile Java source code using javac
, you need the Java Development Kit (JDK).
On Oracle's Java download page, choose the package labelled "JDK".
回答2:
In order to use javac in cmd , JDK must be installed in your system...
javac will not work if you are pointing "bin" folder inside JRE (C:\Program Files\Java**jre7**\bin)
Please check for javac.exe inside your bin folder(C:\Program Files\Java**jdk1.7.0_45**\bin)
javac.exe must be inside JDK(C:\Program Files\Java\jdk1.7.0_45\bin) not inside JRE (C:\Program Files (x86)\Java\jre7\bin) "JRE doesn't come with a compiler. It is simply a java runtime environment. What you need is the developmental kit." in order to use compiler javac
For javac path(Points to remember while setting system env variable)
path = C:\Program Files (x86)\Java\jre7\bin this is wrong
path = C:\Program Files\Java\jdk1.7.0_45\bin this is correct
Make sure "javac.exe" must be inside your "C:\Program Files\Java\jdk1.7.0_45\bin"
Dont confuse with JRE and JDK both are totally different
if you dont have JDK pls download from this link http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html
reference thread for JDK VS JRE What is the difference between JDK and JRE?
Procedure:-
Install JDK
open cmd prompt
type "cd C:\Program Files\Java\jdk1.7.0_45\bin " press enter(path may change based on jdk version and 32bit and 64bit os version)
type "javac" press enter
its done
Now go and change your system environment variable path = C:\Program Files\Java\jdk1.7.0_45\bin
this will set the path permanently
回答3:
The JRE doesn't have javac - you need to download the JDK (Java Development Kit).
回答4:
First, you need to install the jdk, then add the path of bin folder of jdk in the path vaiable.
you can refer to this link
来源:https://stackoverflow.com/questions/18217853/javac-cannot-be-run-and-furthermore-does-not-seem-installed