I have set JAVA_HOME in my system C:\Program Files\Java\jdk1.8.0_
131\bin; and I am trying to run cordova command( cordova build ) on command prompt, but I'm getting the error bellow. I have tried all the ways, but not able to resolve this issue:
ERROR: JAVA_HOME is set to an invalid directory: C:\Program
Files\Java\jdk1.8.0_ 131\bin;
Please, set the JAVA_HOME variable in your environment to match the
location of your Java installation.
You should set it with C:\Program Files\Java\jdk1.8.0_12.
\bin is not required.
JAVA_HOME should point to the home jdk directory, and not to jdk/bin directory.
You need to set the JAVA_HOME like this:
JAVA_HOME="C:\Program Files\Java\jdk1.8.0_131"
Remove the \bin, and also remove the ; at the end. After restart the cmd and run.
Try the following:
Remove \bin from JAVA_HOME path.
Open new command line window.
Run your command as an administrator.
On linux and mac:
To find the path java -XshowSettings:properties -version 2>&1 > /dev/null | grep 'java.home'
result e.g. java.home = /usr/lib/jvm/java-11-openjdk-amd64
copy: /usr/lib/jvm/java-11-openjdk-amd64
Add line in your config bash file (e.g.~/.zshrc): export JAVA_HOME=<resultFirstStep>
On Window 10, the problem was with the semicolon ;.
Go to edit the system environment variables and delete the semicolon at the end of JAVA_HOME value C:\Program Files\Java\jdk1.8.0_144
In other words, convert this C:\Program Files\Java\jdk1.8.0_12; to C:\Program Files\Java\jdk1.8.0_12
You might have to delete your entry in the Windows Dialog and create a new one. If you ever had multiple entries and get the bigger Form view, Windows automatically inserts a ; at the end of each entry, even if you only have one entry left.
JAVA_HOME should be C:\Program Files\Java\jdk1.8.0_172 don't include semi-colon(;) or bin in path. Any jdk version above 7 will work. Also, you need to re-start the cmd
set JAVA_HOME as C:\Program Files\Java\jdk1.8.0_172
do not use semicolon ";" with above JAVA_HOME value
To verify that it is correctly set, Go to command prompt check for C:.......>sdkmanager --list
a complete list will appear that will let you now that it is successfully saved.
else it will show error that JAVA_HOME path is not correctly set.
First try removing the '\bin' from the path and set the home directory JAVA_HOME as below:
JAVA_HOME : C:\Program Files\Java\jdk1.8.0_131
Second Update System PATH:
In “Environment Variables” window under “System variables” select Path
Click on “Edit…”
In “Edit environment variable” window click “New”
Type in %JAVA_HOME%\bin
Third restart your docker.
Refer to the link for setting the java path in windows.
Please remove /bin and even semi colon ; from JAVA_HOME to resolve.
After setting the JAVA_HOME variable, run android studio as administrator
You need to set with only C:\Program Files\Java\jdk1.8.0_12.
And check with using new cmd. It will be updated
I found this while googling the issue with android licences when installing Flutter.
For Linux, update Your ~/.bashrc (or other shell config) file by adding this line at the end:
JAVA_HOME=/usr/local/android-studio/jre
Note: I installed Android studio by following the official installation guide for Linux (link).
For Windows, use the android studio's path to the jre directory and update the environment variable with the right value.
Then, run flutter doctor --android-licenses and press y to review the licences which are not accepted.
Press y for each of the licences. It will ask Accept? (y/N): at the end of the license file.
After You accept all unaccepted licences, You should see:
All SDK package licenses accepted
While copying the JDK PATH, exclude \bin folder in it.
e.g.
C:\Program Files\Java\jdk-15.0.2
your path should look like blow, you just need to edit it and remove \bin folder
C:\Program Files\Java\jdk-15.0.2\bin
Change JAVA_HOME in Environment variable
to this
C:\Program Files\Android\Android Studio\jbr
and since Electric Eel use jbr copy jbr file and replace it into jre then restart ur pc. It worked for me after days of tedious try and error days
i think you need to remove the ';' from the end of the java path.
Check for duplicate entries of JAVA_HOME in system variables.
In my case none of the above answers worked but I had two entries for JAVA_HOME and removing one worked.
I was using jenv
In my case, I was using jenv but did not set the java version, so the path that jenv was pointing actually a Java installation.
When I ran echo $JAVA_HOME, it showed /Users/username/.jenv/versions/system, and there was no such file or directory.
Set a version of java
I just had to do jenv global 15 or jenv local 15, to specify what version I wanted to actually use, and JAVA_HOME changed when I re-ran echo $JAVA_HOME.
First, you need to make sure you installed JDK and then set the path to it. If you have not installed it, you can download and install it from here:
https://www.oracle.com/java/technologies/downloads/
i have set like this in vs code for project.its working for me
JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.8.0_321.jdk/Contents/Home"
Related
As-salāmu ʿalaykum,
I'm having trouble setting JAVA_HOME correctly.
I know that the JAVA_HOME needs to be set to C:\Program Files\Java\jdk1.8.0_92
I know PATH has to be set toC:\Program Files\Java\jdk1.8.0_92\bin
I set both the JAVA_HOME and PATH as a user variable and as a system variable.
When I run Android Studio tells me it's invalid. When I echo out JAVA_HOME, it's set as expected. Any ideas?
You need to set your JAVA_HOME to: C:\Program Files\Java\jdk1.8.0_92\
And set PATH to: C:\Program Files\Java\jdk1.8.0_92\bin so that it can be accessible from cmd
Then you might need to restart the computer
Note:
In some cases JAVA_HOME is specified differently somewhere else such as gradle.properties file. In that case, the global value can be overridden by the project's JAVA_HOME for that specific project.
You didn't mention which windows version you are working on. However, you can try to set the JAVA_HOME variable via the command line as an alternate solution.
Open Command Prompt (make sure you Run as administrator so you're able to add a system environment variable).
Set the value of the environment variable to your JDK (or JRE) installation path as follows:
setx -m JAVA_HOME "C:\Progra~1\Java\jdk1.8.0_XX"
If the path contains spaces, use the shortened path name.
Restart Command Prompt to reload the environment variables then use the following command to check the it's been added correctly.
echo %JAVA_HOME%
You should see the path to your JDK (or JRE) installation.
Besides defining the path you need to enable Java in Windows Defender.
Hint: Disable windows defender and firewall (google it).
Put in the prompt "java -version" and "javac -version" commands again and have fun.
Sorry, english isn’t my first language.
I ran into this error while setting up my Tomcat and Java environmental path:
Neither the JAVA_HOME nor the JRE_HOME environmental variables is
defined. At least one of the 2 environmental variables is needed to
run this program.
In the user variables: I created JAVA_HOME variables and add C:\Program Files\Java\jdk1.8.0_25 to its path. and then did an edit of system variable PATH, added C:\Program Files\Java\jdk1.8.0_25; to the beginning of the its path.
I also created JRE_HOME in user variable and added C:\Program Files\Java\jre1.8.0_25 to its path.
Is it necessary to create JRE_HOME and should I add the JRE path to the system variable also?
This answer explains all the steps with screenshots and examples
Better Use the 8.3 directory-format. In fact No spaces, ever.
JAVA_HOME - your JDK folder
C:\Program Files\Java\jdk1.6.0_45 == C:\PROGRA~1\Java\JDK16~1.0_4
C:\Program Files\Java\jdk1.7.0_71 == C:\PROGRA~1\Java\JDK17~1.0_7
C:\Program Files\Java\jdk1.8.0_25 == C:\PROGRA~1\Java\JDK18~1.0_2
C:\Program Files\Java\jdk1.9.0 == C:\PROGRA~1\Java\JDK19~1.0
JRE_HOME
C:\Program Files\Java\jre6 == C:\PROGRA~1\Java\jre6
C:\Program Files\Java\jre7 == C:\PROGRA~1\Java\jre7
C:\Program Files\Java\jre1.8.0_25 == C:\PROGRA~1\Java\JRE18~1.0_2
C:\Program Files\Java\jre1.9.0 == C:\PROGRA~1\Java\JRE19~1.0
Addition to PATH - best practice!
USE WINDOWS+R
Enter C:\Windows\system32\systempropertiesadvanced.exe
Add ;C:\ProgramData\Oracle\Java\javapath; to the end of PATH
(System Variables not User Variables).
Click OK, explore to C:\ProgramData\Oracle\Java\ and rename javapath folder (from C:\ProgramData\Oracle\Java\javapath\) to javapath_old.
Create new folder named javapath.
Start CMD and browse into (the now empty) C:\ProgramData\Oracle\Java\javapath\.
Run to create symbolic links:
ln -s "C:\Program Files\Java\jre7\bin\java.exe" java.exe
ln -s "C:\Program Files\Java\jre7\bin\javaw.exe" javaw.exe
ln -s "C:\Program Files\Java\jre7\bin\javaws.exe" javaws.exe
Done with PATH and *_HOME, now let's continue with the Windows Registry.
Open up you preferred registry editor (Registry Workshop is the best), browse HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Development Kit notice all installed versions are shown as keys, double click CurrentVersion (REG_SZ value) and modify its data to your preferred SDK version, mine is 1.7 (For Android Studio)
Do the same for HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment (with CurrentVersion)
Close down java-based programs such as eclipse or IntelliJ,
Open up task-manager- processes tab,
Look for explorer.exe, cmd.exe and java(*something*).exe programs,
Right-click eache and click End Task (not "End Process-Tree"!)
Click File➩New Task➩enter explorer.exe.
The changes you've done above were applied successfully
No need to reboot, no need to log-off/on again.
You really do not need to add JRE_HOME to the system variables. Tomcat looks for JAVA_HOME or JRE_HOME to get itself start. This is because tomcat require some java library to get itself started. Tomcat will provide additional debugging functionality if Jdk is provided instead of Jre. Additional details here
Adding {JAVA_HOME_DIR}/bin to your path would enable to access java from anywhere.
After modifying system variables , it is important to open new console window
Try this...
For Java,
In the User variables, add PATH value is C:\Program Files\Java\jdk1.8.0_25\bin;
For Tomcat
In the System variables, add JAVA_HOME value is C:\Program Files\Java\jdk1.8.0_25
Now classpath has been set to your machine. You can access java from anywhere in your machine.
After Done this, Go to Command Prompt and go to ApacheTomcat*x.x and move to bin folder,,
Start the Server
startup.bat
For check Tomcat running status, Go to your browser, and Paste the URL,
http://localhost:8080/
Stop the Server
shutdown.bat
I am on JDK 8u25 on Windows 8, and I am experiencing a problem with my Java installation. I can run javac perfectly fine, but running java produces this error message:
The system cannot find the file C:\ProgramData\Oracle\Java\javapath\java.exe
How do I fix this?
I think the problem has to do with my environment variables.
The important variables, as I have set them, are:
JAVA_HOME – C:\Program Files\Java\jdk1.8.0_25
CLASSPATH – .;%JAVA_HOME%\lib
PATH – <other paths omitted>;%JAVA_HOME%\bin
And their expansions, as viewed with set in cmd, are:
JAVA_HOME – C:\Program Files\Java\jdk1.8.0_25
CLASSPATH – .;C:\Program Files\Java\jdk1.8.0_25\lib;%CLASSPATH%;
PATH – C:\ProgramData\Oracle\Java\javapath;C:\Program Files\Java\jdk1.6.0_45\bin;<other paths omitted>;C:\Program Files\Java\jdk1.8.0_25\bin
The full output of set can be viewed here.
I've got a similar problem I'm currently working on solving. I can't say this will solve your error since there may be issues with other software (which is my case with Eclipse Luna).
Java is using the path given in your PATH variable, which is,
C:\ProgramData\Oracle\Java\javapath
Go to this folder (ProgramData is hidden, so unhide it if necessary) and right click on the java.exe symlink. You'll see in the Target field where it's looking for java.exe. It may be pointing to the java.exe file from your previous jdk1.6.0_45 install. Either paste in new shortcuts here or change the PATH setting as others have mentioned.
I've found that the Java installer doesn't change the javapath or update the system path, at least when going from 1.8 to 1.7. In my case changing the shortcuts only led to a problem with Eclipse on startup.
EDIT:-----
After playing with javapath folder shortcuts it turns out you need symlinks, at least for Eclipse. See, Windows how to create directory symlink.
You don't need the /d switch for a file symlink,
mklink java.exe "C:\Program Files\Java\jdk1.8.0_20\bin\java.exe"
mklink javaw.exe "C:\Program Files\Java\jdk1.8.0_20\bin\javaw.exe"
mklink javaws.exe "C:\Program Files\Java\jdk1.8.0_20\bin\javaws.exe"
This now works for me.
Why Oracle did such a poor way to point to java is beyond me. We solved this problem by creating a new link to the JDK
mklink /d C:\ProgramData\Oracle\Java\javapath "C:\Program Files\Java\jdk1.8.0_40\bin\"
The same would work for a JRE if that is all that is required.
This replaces the old symlinks in C:\ProgramData\Oracle\Java\javapath (if they existed previously)
I had in PATH:
C:\ProgramData\Oracle\Java\javapath;C:\Program Files\Java\jdk1.8.0_92\bin;<others omitted>
I removed:
C:\ProgramData\Oracle\Java\javapath;
and that fixed the issue for me. java -version now gives details about the Java version, etc.
This will solve all problems relating to Java and environment variables:
Make your way to Windows' Environment Variables dialog.
Under System variables, select the variable named Path. Click Edit...
Remove the entry that looks like:
C:\ProgramData\Oracle\Java\javapath
Add the path of your JDK/JRE's bin folder.
Don't forget to set JAVA_HOME.
I got same error while running JAVA command. To resolve this, I moved the java path as the first entry in the path, and it resolved the issue. Please have look at this screenshot for reference:
Updating the PATH Environment Variable
If you do not set the PATH variable, you need to specify the full path to the executable file every time you run it, such as:
C:\> "C:\Program Files\Java\jdk1.8.0\bin\javac" MyClass.java
It is useful to set the PATH variable permanently so it will persist after rebooting.
To set the PATH variable permanently, add the full path of the jdk1.8.0\bin directory to the PATH variable. Typically, this full path looks something like
C:\Program Files\Java\jdk1.8.0\bin. Set the PATH variable as follows on Microsoft Windows:
Click Start, then Control Panel, then System.
Click Advanced, then Environment Variables.
Add the location of the bin folder of the JDK installation to the PATH variable in System Variables.
The following is a typical value for the PATH variable:
C:\WINDOWS\system32;C:\WINDOWS;C:\Program Files\Java\jdk1.8.0\bin
Note:
The PATH environment variable is a series of directories separated by semicolons (;) and is not case-sensitive. Microsoft Windows looks for programs in the PATH directories in order, from left to right.
You should only have one bin directory for a JDK in the path at a time. Those following the first instance are ignored.
If you are not sure where to add the JDK path, append it.
The new path takes effect in each new command window you open after setting the PATH variable.
There are 2 versions of jdk in your PATH VARIABLE jdk1.6.0_45 and jdk1.8.0_25. Try removing the first one ie. jdk1.6.0_45 from the PATH
If you're on a corporate PC that's fairly restricted by group policy, this might work....
Assuming that
your Windows PATH includes C:\ProgramData\Oracle\Java\javapath
you have JDK installed to C:\Program Files\Java\jdk1.8.0_60\bin
Then create the following text file mklink.bat and put it on your desktop:
rem mklink.bat
mklink /d C:\ProgramData\Oracle\Java\javapath "C:\Program Files\Java\jdk1.8.0_60\bin"
pause
Now right-click it and choose "Run as Administrator". Provide admin credentials. The script should report success. Now you can compile or run Java.
This usually happens when you update the java,
the easiest way to solve this is to just uninstall the JDK & then reinstall it.
NOTE: This doesnt remove the path or classpath so no need to worry.
Uninstall all JDKs installed on your computer from the Java Control Panel
Search for C:\ProgramData\Oracle\Java and delete that directory and all files contained within. You can do this from the command line using rmdir /S C:\ProgramData\Oracle\Java
Then search for C:\ProgramData\Oracle and delete the oracle folder. You can do this using rmdir /S C:\ProgramData\Oracle
Now install JDK and set the path.
Run the program.You won't find the same problem anymore.
This problem exists when you upgrade from one version to another.because jdk is not automatically upgraded.
For the same you can change the environmental varibles.
In system variables look for the PATH and add the jdk bin location in the front of the string(not at the back).
Once you have done that check in CMD if "java" and "javac" works.
if it works, again go to system variables.
add "CLASSPATH" A the variable and set value " .
c:\Program Files\Java\jdk1.8.0_91\lib;"
There must be two or more PATH variables. Try merging all of them into one using semi-colon (;)
I got the same after installing java8 from a non-permissioned account.
To fix I simply reinstalled from admin user account.
This created the quoted directory with file links to java exes.
I had also similar problem where by I had to un-install JDK 1.8 and needed jdk 1.7.
What i did was removed the symbolic links from the javapath and then imported the shortcuts of java, javaw, javaws from the bin directory to the javapath folder. However, I found some permission issues in the enterprise laptop where by I did not have the privilege to modify/ update this directory. I had given appropriate permission from the administrator and there by resolved it.
c:\ProgramData\Java\javapath is used for symlinks. You can of course add the full path to your Java Path to %PATH%, but equally you can create a symlink to the path to the above location.
Open CMD as Administrator.
Type mklink java.exe (full path to your Java.exe)
eg
mklink java.exe "C:\Program Files\Java\jdk1.8.0_25\bin\java.exe"
Don't worry.
Just uninstall jdk as well as jdk updates
Before re installing jdk ,delete the oracle folder inside programData hidden folder in C:\
Then reinstall.
Set the following,
JAVA_HOME
CLASSPATH
PATH
JRE_HOME ( is optional)
Please remove "C:\ProgramData\Oracle\Java\javapath\java.exe" from the Path variable and add your jdk bin path. It will work.
In my case the I have removed the the above path and added my JDK path which is "C:\Program Files\Java\jdk1.8.0_221\bin"
For New version of Java JavaPath folder is located
64 bit OS
"C:\Program Files \Common Files\Oracle\Java\javapath\"
X86
"C:\Program Files(x86) \Common Files\Oracle\Java\javapath\"
This will solve all problems relating to Java and environment variables:
Make your way to Windows' Environment Variables dialog.
Under System variables, select the variable named Path. Click Edit...
Remove the entry that looks like:
C:\ProgramData\Oracle\Java\javapath
Add the path of your JDK/JRE's bin folder.
Don't forget to set JAVA_HOME.
This helped me.......:-)
For me it worked like this:
On your desktop go to Search->View advanced system settings->Environment Variables
Under System Variables look for path and click Edit.
Click on New and add the new Path and move it to the top.
To find your java path if you don't know where it is installed in cmd type where javac
<>\Common Files\Oracle\Java\javapath\ is now created as a junction, no symlinks anymore
I have downloaded both Java jdk1.7.0_06 and Java jre7. and i added the following system variable JAVA_HOME C:\Program Files\Java\jdk1.7.0_06\bin to my windows 7. But when I type the following in the CMD command line on my windows 7 C:\activiti-5.10\activiti-5.10\setup>ant demo.start to run a demo application I got the following error in the command line '
"java.exe"' is not recognized as an internal or external command, operable program or batch file
So does anyone know how i can solve this problem ?
BR
If you look at the "ant.bat" file, you will see that it looks for the "java" command in the following way:
If the %JAVACMD% environment variable is set, then it uses that.
Otherwise, if the %JAVA_HOME% environment variable is set, it tries to use %JAVA_HOME%\bin\java.exe
Otherwise, it tries to use java.exe; i.e. it will look on your %PATH%.
In your case, you have %JAVA_HOME% set ... but set to the Java installation's "bin" directory, not to the root of the installation. So the Ant.bat script looks in the wrong place for java.exe.
Just set %JAVA_HOME% correctly, and it should work.
JAVA_HOME C:\Program Files\Java\jdk1.7.0_06
As you can see from the above, you do not need to have the Java "bin" directory on your %PATH% for Ant to work, but it is a good idea to set it anyway. That way you can run the Java commands simply from the command line.
The setting of %CLASSPATH% is not relevant to this problem. Indeed, unless the build.xml file is broken, Ant will ignore your %CLASSPATH% environment variable.
You need to put the file java.exe in your PATH variable but the JRE in JAVA_HOME
JAVA_HOME is the path of JDK root folder.eg: C:\Program Files\Java\jdk1.7.0_06 but path define C:\Program Files\Java\jdk1.7.0_06\bin
JAVA_HOME C:\Program Files\Java\jdk1.7.0_06
JRE_HOME C:\Program Files\Java\jre1.7.0_06
path = C:\Program Files\Java\jdk1.7.0_06\bin;C:\Program Files\Java\jre1.7.0_06\bin
Typically JAVA_HOME should be the parent directory of the "bin" folder.(jre or jdk)
In this case ant expects the java to be from the JDK.
try following in a cmd window
set JAVA_HOME=C:\Program Files\Java\jdk1.7.0_06
set path="%JAVA_HOME%/bin;%path%;
ant
(side note: adding java.exe to path is not a requirement for ant; it is a convenience thing for the user)
Just delete the following set of files from your %windir/System32 folder. Actually deleting java.exe is enough but for consistency sake just delete all the java related binaries.
java.exe
javaw.exe
javaws.exe
Actually oracle windows installer places a copy of these files into %windir/System32 folder (which I don't understand why) but looks like they are not needed (as they are available anyway under JDK folder where you install them).
I have tried all the various solutions posted in the SO and other forums as well but none of them worked for me. I have also set all the relevant environment variables (JAVA_PATH, CLASS_PATH etc) correctly as well. Finally this is the only solution that has worked for me.
Go to the \squirrel-sql-3.9.0>squirrel-sql.bat .open that squirrel-sql.bat in Notepad and comment out the existing logic which is
=======================================
if exist "%IZPACK_JAVA%\bin\javaw.exe" (
set LOCAL_JAVA=%IZPACK_JAVA%\bin\javaw.exe
) else (
set LOCAL_JAVA=javaw.exe
)
echo Using java: %LOCAL_JAVA%
=================================
and add the below logic
#echo off
set LOCAL_JAVA=C:\Program Files (x86)\Java\jre7\bin\javaw.exe
echo Using java: %LOCAL_JAVA%
================================
make sure you add the correct path of javax.exe while adding above logic set LOCAL_JAVA=
and start the .bat file from CMD ..that's it. It should work. It worked for me.
I started getting this error in Android Studio after I updated it to version "Electric Eel".
It happened because Android Studio has changed where they put their JRE:
it used to be C:\Program Files\Android\Android Studio\jre
but now it is C:\Program Files\Android\Android Studio\jbr
To fix:
updated my JAVA_HOME environment variable to point to the new java location (C:\Program Files\Android\Android Studio\jre)
and then restarted Android Studio, and now it is fixed.
I agree with the above explanation but if the problem still persists try setting:
CLASSPATH = C:\Program Files\Java\jdk1.7.0_06\bin
I am getting error while doing 'play run'
"Could not execute the Java executable, please make sure the JAVA_HOME environment variable is set properly (the Java executable should reside at JAVA_HOME/bin/java)."
But I can confirm that , JAVA_HOME is set correctly, as I am able to run 'java' command from console i.e. DOS prompt.
Can anyone please guide me on this?
Set user variable
JAVA_HOME to C:\Progra~1\Java\jdk1.7.0_04
and
extend the system variable
Path with %JAVA_HOME%\bin;
works for me
I had the same problem on Windows 7. echo %JAVA_HOME% returned C:\Programmes\Java\jdk1.7.0, which seemed correct. However, in Windows 7, even though path looks like that in explorer, the "real" path to use with cmd is C:\Program Files\Java\jdk1.7.0.
I updated JAVA_HOME and restarted cmd — otherwise, the terminal wouldn't refresh its variables — and it worked smoothly.
Being able to run java from your command line does NOT indicate that you have set the JAVA_HOME variable. Do you know how to do that?? Or do you know how to check if this variable exist?
Here is a quick way IF you are using Windows: Right click My Computer (or Computer in Windows 7) then click the tab Advanced then environment variables. In the System variables check if there is an entry with the variable JAVA_HOME. If NOT create one (by clicking new) giving JAVA_HOME in variable name and the path of your jdk in the variable value. IF let's say, your jdk is installed on the following path: c:\jdk6 in your pc THEN this should be your variable value. Click Ok, Ok again and then run your app again!
Have you done echo %JAVA_HOME%?
Several issues:
JAVA_HOME (a variable used by the JVM) is not the same than PATH (a variable used by the OS to locate directories where to find executables). Doing java.exe just shows that the bin directory of Java is in PATH, not that JAVA_HOME points where it should (or even it exists)
Also, Windows usually does not use the PATH variable, but instead treats java specially and stores its location in the register (do an echo %PATH% to check this).
In conclussion: You cannot assume JAVA_HOME is set; check for it directly and set it (Control Panel-> System -> Advanced).
Make sure you use a DOS-Path in JAVA-Home. Meaning no fakes from Win-7 C:\Programme in real C:\Program Files and no blank in path.
C:\>dir /x Prog*
09.08.2011 13:55 <DIR> PROGRA~1 Program Files
21.08.2011 20:25 <DIR> PROGRA~2 Program Files (x86)
This is a safe solution.
echo %JAVA_HOME% is indeed always a good idea to.
If you have a 64 bit Windows version, make sure you have both the 32bit and 64bit version of Java installed (so there must be a Java directory in both Program Files and Program Files (x86). That was my problem.
I updated my jdk from 1.6.0_14 to 1.7.0_10 and my jre6 to jre7 and had the same problem on XP.
I then deleted JAVA_HOME and added it again and it worked.
I also added JRE_HOME as a System Variable
JAVA_HOME --> C:\Program Files\Java\jdk1.7.0_10
JRE_HOME --> C:\Program Files\Java\jre7