When I am trying to run tomcat using startup.bat
I get the following error,
The JAVA_HOME environment variable is not defined correctly
This env
Avoid semicolon in the end of any environment variables... from JAVA_HOME or JRE_HOME
JAVA_HOME=C:\Program Files\Java\jdk1.6.0_25\bin
and
JRE_HOME=C:\Program Files\Java\jdk1.6.0_32\jre
should be like as shown...
Set Environment Variable ([Windows Key]+[Pause Key], switch to "Advanced", click "Environment Variables", in "System Variables" (lower list), click "New" (or "Edit" if you already have it),
name: JAVA_HOME
value: C:\PROGRA~1\Java\JDK16~1.0_3
for C:\Program Files\Java\jdk1.6.0_32
click "ok",
go to "path" in "system variables",
add ; at the end of the line (unless there is already one there),
add: C:\PROGRA~1\Java\JDK16~1.0_3\bin
click "ok" through all. -- restart your computer (advisable)
I had Win 8 x86 installed. My Path
variable had entry C:\Program Files\Java\jdk1.6.0_31\bin
and I also had following variables:
JAVA_HOME
: C:\Program Files\Java\jdk1.6.0_31;
JRE_HOME
: C:\Program Files\Java\jre6;
My tomcat is installed at C:\Program Files\Apache Software Foundation\apache-tomcat-7.0.41
And still it did not worked for me.
I tried by replacing Program Files
in those paths with Progra~1
. I also tried by moving JAVA to another folder so that full path to it does not contain any spaces. But nothing worked.
Finally environment variables that worked for me are:
Program Files
i.e. C:\Program Files\Java\jdk1.6.0_31\bin
JAVA_HOME
: C:\Program Files\Java\jdk1.6.0_31
JRE_HOME
So what I did is removed JRE_HOME
and removed semicolon at the end of JAVA_HOME
. I think semicolon should not be an issue, though I removed it. I am giving these settings, since after a lot of googling nothing worked for me and suddenly these seem to work. You can replicate and see if it works for you.
This also worked for Win 7 x64, where
C:\Program Files (x86)\Java\jdk1.7.0_17\bin
JAVA_HOME
is set to C:\Program Files (x86)\Java\jdk1.7.0_17
(without semicoln)Please tell me why this worked, I know removing JRE_HOME
was weird solution, but any guesses what difference it makes?
I had similar problem and please note that we need not set JAVA_HOME unless we are going to use debug mode. tomcat in windows 7 can handle spaces in environment variables the problem is because of "bin" in the path. setting JRE_HOME to C:\Program Files (x86)\Java\jre1.8.0_65 solved my problem and tomcat is up and running without any trouble
I set the
variable name : JAVA_HOME value : C:\Program Files\Java\jdk1.6.0_32
I set these properties in system/environment variables without semicolon, tomcat is running on my system.
It really works.
Set environment variables for JAVA_HOME and JRE_HOME without the \bin. That worked for me