简体   繁体   中英

setting up classpath. javac is not recognized

I am trying to run my java program from command line.

I read an article about setting up classpath, but I get an error of javac is not recognized as internal or external command. What should I do? (I dont want to set a permanent CLASSPATH) This is what I have done in my command line

D:\user> set path=%path%;C:\Program Files\Java\1.7.0_07\bin

D:\user> cd testing

D:\user\testing> javac firstProgram.java
'javac' is not recognized as an internal or external command,
operable program or batch file.

Thank you

Assuming that the PATH is correct 1 , the most likely cause is that you have a JRE installation ... and a JRE doesn't include a java compiler. You need a JDK installation if you want to compile from the command line.

(You can confirm this by looking in the C:\\Program Files\\Java\\1.7.0_07\\bin directory to see if it contains a javac.exe file. A JRE won't ...)

Where can I find the Java compiler to download..

You need to download one of the JDK installers; see http://www.oracle.com/technetwork/java/javase/downloads/index.html


1 - I don't think quotes are required in a PATH variable on Windows. At least that's what various examples that Google found for me seem to imply. But I've never really understood the logic behind quoting in Windows ...

Better do it in Environmental variable and check it!

在此输入图像描述

Its an issue related to Program Files .

First make sure that your JDK Folder is installed in Program Files or Program Files(x86) or any other folder.

Then you should use the path of bin folder in " ". Because command prompt does break the string at space. When you will write it in " " then it will take is as a whole String.

You try these commands

set path=%path%;"C:\Program Files\Java\1.7.0_07\bin"

or

set path=%path%;"C:\Program Files(x86)\Java\1.7.0_07\bin"

It might help you to get out of this.

try below command is recognized from command prompt C:\\Program Files\\Java\\1.7.0_07\\bin\\javac ab.java

This is just to verify your javac

Here's how you can set the path temporary, meaning if you close and reopen "command prompt" you will have to set the path again.

Assuming the path is C:\\Program Files\\Java\\jdk1.6.0\\bin

TYPE IN C:\\Program Files\\Java\\jdk1.6.0\\bin AND HIT ENTER that's it.

命令D:\\user\u0026gt; set path=%path%;C:\\Program Files\\Java\\1.7.0_07\\bin对我来说效果很好

Adding few more information to this:

Please check the version of JDK and JRE installed on your computer. Recently I faced the same problem even after setting the PATH. It gives the error "javac - command is not recognised"

Solution is there must be similar versions of JDK as well as JRE

Eg: JDK 1.7.75 along with JRE 1.7.75

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