Java command works but javac command doesn't

亡梦爱人 提交于 2021-02-17 06:12:31

问题


I just install jdk and jre version 8 In windows. Environment variable already set. I try run "java -version" in cmd and it shows the version of java installed. But when I try to compile java project with "javac projectName" system says javac is not recognized as internal or external command. So can anyone tell me how to fix it?

here is my environment variable:

C:\Users\Foody>echo %PATH% C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\NVIDIA Corporation\Ph ysX\Common;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\Sy stem32\WindowsPowerShell\v1.0;C:\Program Files\Microsoft\Web Platform Installer ;C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0;C:\Program Fi les (x86)\Windows Kits\8.0\Windows Performance Toolkit;C:\Program Files\Microso ft SQL Server\110\Tools\Binn;C:\Program Files (x86)\Common Files\lenovo\easyplu ssdk\bin;C:\Program File\Java\jdk1.8.0_60\bin;C:\Program File\Java\jdk1.8.0_60\bin;

C:\Users\Foody>


回答1:


There is a typo in your variable path:

C:\Program File\Java\jdk1.8.0_60\bin;C:\Program File\Java\jdk1.8.0_60\bin\;

Should be and you do not need it twice

C:\Program Files\Java\jdk1.8.0_60\bin;



回答2:


The JRE only contains the java executable, and not javac. So apparantly your path points to the JRE installation dir, not the JDK.




回答3:


if the above text is correct, you have written

"C:\Program File\Java\jdk1.8.0_60\bin;C:\Program File\Java\jdk1.8.0_60\bin\;"

it must be "Program Files"

C:\Program Files\Java\jdk1.8.0_60\bin;C:\Program Files\Java\jdk1.8.0_60\bin\



回答4:


On a windows system also check the if the path variable includes you're java installation. Use

set

Perhaps you want also want to have look at Oracle Java help

Regards Patrick



来源:https://stackoverflow.com/questions/36083859/java-command-works-but-javac-command-doesnt

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