简体   繁体   中英

Java JDK Installation

OK, what am I doing wrong, this is driving me nuts.

I am trying to install the latest JDK (1.6.0_23). So, I downloaded it from Oracle's awful site and then ran the installation. I installed it to C:\\Java\\jdk1.6.0_23

Then, I created a JAVA_HOME User Variable that pointed to C:\\Java\\jdk1.6.0_23. I then added a piece to the end of my Path environment variable that says %JAVA_HOME%\\bin.

However, when I try to simply open a command prompt and run simple java commands, I am told it is not a recognizable command. I have to manually cd into the that bin directory to do anything.

Do I also need a Classpath variable that points to the JRE? I noticed there was a Classpath variable there previously that pointed to jre/lib/QTJava.zip, but I deleted it.

If you have the JDK installed and a JAVA_HOME variable setup, do I still need the JRE in the classpath? I am running Windows 7 and do all of my development in Eclipse.

From http://social.answers.microsoft.com/Forums/en-US/vistainstall/thread/48b23109-9fbc-47c5-a5d1-465773f94704

(at the end)

1) Enable 'delayed variable expansion' in the registry (see http://batcheero.blogspot.com/2007/06/how-to-enabledelayedexpansion.html )

2) Change the '%' signs around var2 to '!', eg "%var2%" becomes "!var2!"

I've done some limited testing on Windows 7 and this appears to fix the problem.

Maybe try that, see if it fixes it (I don't have windows here to try)

Do I also need a CLASSPATH variable that points to the JRE?

Strictly speaking, no. The CLASSPATH variable may be used if you try to run a java class and you don't use the -cp or -jar options.

The CLASSPATH variable doesn't need to point to the JRE. The java.exe command etc all know where to find the JRE's runtime classes. (And they don't look on the CLASSPATH for them anyway.)

For the PATH problem, try running:

C:\Java\jdk1.6.0_23\bin\java.exe -version

If that doesn't work then there's a problem with your actual installation. If it does work, try looking at what JAVA_HOME and PATH are set to in the environment variables of the command shell .

Maybe the problem is because you set JAVA_HOME as a user variable, but trying to reference it from the PATH which is a system variable (or is it?). You cannot do this, because system variables are evaluated before user variables.

There are two possible solutions: 1. Set JAVA_HOME as a system variable instead 2. Create a new user variable PATH and set %JAVA_HOME%\\bin there. The user PATH and the system PATH variables will be concatenated at runtime automatically.

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