简体   繁体   中英

javac not recognized java 7

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?

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.

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

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

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