java comand works but not javac?

て烟熏妆下的殇ゞ 提交于 2019-12-10 10:53:59

问题


ok so I got a new PC

Windows 7 Pro 64 bit Service Pack 1

I installed jdk-7u25-windows-x64 ( jdk 1.7.0_25)

It is installed in default location C:\Program Files\Java\jdk1.7.0_25

I set the JAVA_HOME environment variable to C:\Program Files\Java\jdk1.7.0_25

I added %JAVA_HOME%\bin to the Path environment variable (yes I used a ; before I added it)

Clicked Ok

Closed all CMD windows opened them up

And now If I run the command java I get the expected output

But If I run the javac command I get this

C:\Users\AJ>javac
'javac' is not recognized as an internal or external command,
operable program or batch file.

I have tried Fiddling with the path but no luck, and have restarted my PC etc. no luck

Also it seems to work if I am in the jdk\bin directory

C:\>cd C:\Program Files\Java\jdk1.7.0_25\bin

C:\Program Files\Java\jdk1.7.0_25\bin>javac -version
javac 1.7.0_25

C:\Program Files\Java\jdk1.7.0_25\bin>

how do I get javac command to run correctly like java is doing


回答1:


I had previously problems with the path containing a blank. I would suggest to change the path from

C:\Program Files\Java\jdk1.7.0_25

to

C:\Progra~1\Java\jdk1.7.0_25

Hope this solves your problem!




回答2:


You can also try to specify the full pathname.

Instead of

%JAVA_HOME%\bin

try

C:\Program Files\Java\jdk1.8.0_101\bin

This worked for me on Windows 10 64-bit Education Edition with Java 8.0.101



来源:https://stackoverflow.com/questions/19565237/java-comand-works-but-not-javac

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!