javac not recognized java 7

戏子无情 提交于 2019-12-01 07:40:43

问题


I have recently installed jdk7 on my windows vista. I have used default installation in C:\Program Files\Java\jdk1.7.0_02\ with javac stored in C:\Program Files\Java\jdk1.7.0_02\bin. I have configured my PATH and CLASSPATH environmental variables (both for my user and system variables) with C:\Program_Files\Java\jdk1.7.0\bin and JAVA_HOME (as my user variable) with C:\Program_Files\Java\jdk1.7.0\ (I have also tried a version with C:\Program_Files\Java\jdk1.7.0_02\bin).

java -version produces desired output. I can also run javac from the C:\Program_Files\Java\jdk1.7.0\bin directory with no problem. However when I try to run it from somewhere else I got the error that it is not recognized. Where can be the problem. Am I missing anything?


回答1:


Open a command-line window, type "path" and check if "C:\Program Files\Java\jdk1.7.0_02\bin" is listed. If not try setting the path in that window (just to check if it works): "set path=C:\Program Files\Java\jdk1.7.0_02\bin\" and try running "javac" again.




回答2:


Do check properly in your path variables, you must have kept a space somewhere, else it must run. Do check properly, something is wrong while setting up path and classpath variables. Like for example, Your path variable already has something like say C:\Apache\bin\servlet-api.jar, now since you adding java to it you might have kept one space like

C:\Apache\bin\servlet-api.jar; C:\Program_Files\Java\jdk1.7.0\bin

you have to remove that space, and do it like this

C:\Apache\bin\servlet-api.jar;C:\Program_Files\Java\jdk1.7.0\bin

Do check properly, you must have left some space(gap) somewhere

Example :

Variable : JAVA_HOME
Value : C:\Program_Files\Java\jdk1.7.0

Variable : PATH
Value : %JAVA_HOME%\bin

Now open cmd, and type echo %JAVA_HOME% This must show your location to JAVA_HOME as set before.

**EDIT : I have configured my PATH environmental variables (both for my user and system variables) with C:\Program_Files\Java\jdk1.7.0\bin and JAVA_HOME (as my user variable) with C:\Program_Files\Java\jdk1.7.0**

** But before that you are saying that your java is installed at this location**

C:\Program Files\Java\jdk1.7.0_02\bin

why this different location, you are setting it for jdk1.7.0 but you said it's inside jdk1.7.0_02.

Hope that might help

Regards




回答3:


You have an underscore in your entries that were put in the PATH variable. This will not work correctly.



来源:https://stackoverflow.com/questions/8711960/javac-not-recognized-java-7

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