Tomcat is not running even though JAVA_HOME path is correct
Solution 1
Try installing java somewhere else - in a directory without spaces. Set again the JAVA_HOME
variable and try again. I remember Tomcat had some problems on Window XP with spaces if any variables it was using while starting contained spaces. Maybe it's similar with Windows 7.
I remember I had to change some lines in Tomcat java classes which were handling Tomcat startup.
@Edit: Luciano beat me to noticing it but you should also remove bin
from JAVA_HOME
@Edit: I also remember that another fix (didn't test it myself, though) was to set JAVA_HOME
to the shorthand version e.g. C:\Progra~1\Java\jdk1.6.0_25
Solution 2
I think that your JAVA_HOME should point to
C:\Program Files\Java\jdk1.6.0_25
instead of
C:\Program Files\Java\jdk1.6.0_25\bin
That is, without the bin folder.
UPDATE
That new error appears to me if I set the JAVA_HOME with the quotes, like you did. Are you using quotation marks? If so, remove them.
Solution 3
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...
Solution 4
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:
- Kept path variable as is with full
Program Files
i.e.C:\Program Files\Java\jdk1.6.0_31\bin
JAVA_HOME
:C:\Program Files\Java\jdk1.6.0_31
- Deleted
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
- Path variable contained
C:\Program Files (x86)\Java\jdk1.7.0_17\bin
JAVA_HOME
is set toC:\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?
Solution 5
Remove the 'bin' from JAVA_HOME. That solves the issue.
Comments
-
Quazi Irfan almost 2 years
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 environment variable is needed to run this program NB: JAVA_HOME should point to a JDK not a JRE
But then I try
C:\>echo %java_home%
and I get the following resultC:\Program Files\Java\jdk1.6.0_25\bin
I have even tried setting
JAVA_HOME
manually to system variable list, but this issue remains.What can I do to solve it?
I am using Windows 7.
Update
After setting a new system variable named JAVA_HOME and setting its path to
"C:\Program Files\Java\jdk1.6.0_25\bin\"
, I tried the start up script again and this time I get a new error.D:\Work\apache-tomcat-6.0.35\bin>startup.bat Files\Java\jdk1.6.0_25"" was unexpected at this time.
Any idea what this error means?
I even tried setting the path to
"C:\Program Files\Java\jdk1.6.0_25\"
(that is without bin) but same error occurs.