Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tomcat is not running even though JAVA_HOME path is correct

Tags:

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 result

C:\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.

like image 273
Quazi Irfan Avatar asked Jan 13 '12 23:01

Quazi Irfan


People also ask

How do I run Java on Tomcat 7?

Navigate to your %TOMCAT_HOME%\bin directory (for example, C:\Program Files\Apache Tomcat\Tomcat7\bin) and double-click tomcat7w.exe. Click the Java tab, deselect the check box next to Use default and select the path to Java virtual machine file ( C:\ [Java folder path]\bin\server\jvm.dll or C:\ [Java folder path]\bin\client\jvm.dll) and click OK.

How to set JRE_home for tomcat8?

To run Tomcat8 you need to have JRE_HOME defined in Env Variable. JAVA_HOME alone will not do even if correctly set. You should select the JRE that is inside SDK, i.e. one with your JDK (SDK) installation. In other words your JAVA_HOME + \jre When compiling JDK is needed to support JSP, to compile Servlets which are generated from *.jsp files.

How to start the Apache Tomcat service?

Locate the Apache Tomcat service, and then verify that Running is listed in the Status column. If it is not running, try to start the service manually by selecting it and clicking Start. II. Error message from a Java update is received (error code 1)

How do I know if Tomcat is running or not?

Locate the Apache Tomcat service, and then verify that Running is listed in the Status column. If it is not running, try to start the service manually by selecting it and clicking Start. You receive an error message from a Java update (error code 1)


1 Answers

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

like image 76
Mateusz Dymczyk Avatar answered Sep 29 '22 08:09

Mateusz Dymczyk