Question

I am attempting to create a digest for some passwords.

When running the following command

C:\Program Files\apache-tomcat-7.0.34\bin> digest.bat -a SHA-256 somepassword

i receive the following error

The JRE_HOME environment variable is not defined correctly
This environment variable is needed to run this program

The value of JRE_HOME is C:\Program Files\Java\jre7

I have tried .; at the front \bin at the back (with and without a semicolon and/or trailing backslash) and still the problem persists.

  1. The version of tomcat is 7.0.34

  2. The version of java is jre7

  3. The OS is Win7 Pro 64 bit

My next step is to install a different version of the JRE and try again so any help is appreciated.

Was it helpful?

Solution

From the %CATALINA_HOME%\bin\tool-wrapper.bat file, that is referenced from inside the digest.bat:

rem   JAVA_HOME       Must point at your Java Development Kit installation.
rem                   Using JRE_HOME instead works as well.
rem
rem   JRE_HOME        Must point at your Java Runtime installation.
rem                   Defaults to JAVA_HOME if empty. If JRE_HOME and JAVA_HOME
rem                   are both set, JRE_HOME is used.


In other words, just set the JAVA_HOME to point to JDK (not JRE) installation and all will work just fine (tested it on my machine).

Example JAVA_HOME from my machine:

JAVA_HOME=C:\Program Files\Java\jdk1.7.0_17

UPDATE

From the running.txt file located in the Tomcat directory:

(3) Configure Environment Variables

Tomcat is a Java application and does not use environment variables. The variables are used by the Tomcat startup scripts. The scripts use the variables to prepare the command that starts Tomcat.

(3.1) Set CATALINA_HOME (required) and CATALINA_BASE (optional)

The CATALINA_HOME and CATALINA_BASE environment variables are used to specify the location of Apache Tomcat and the location of its active configuration, respectively.

The CATALINA_HOME environment variable should be set as defined in (2.2) above. The Tomcat startup scripts have some logic to set this variable automatically if it is absent (based on the location of the script in Unixes and on the current directory in Windows), but this logic might not work in all circumstances.

The CATALINA_BASE environment variable is optional and is further described in the "Multiple Tomcat Instances" section below. If it is absent, it defaults to be equal to CATALINA_HOME.

(3.2) Set JRE_HOME or JAVA_HOME (required)

The JRE_HOME variable is used to specify location of a JRE that is used to start Tomcat.

The JAVA_HOME variable is used to specify location of a JDK. It is used instead of JRE_HOME.

Using JAVA_HOME provides access to certain additional startup options that are not allowed when JRE_HOME is used.

If both JRE_HOME and JAVA_HOME are specified, JRE_HOME is used.


Additional reading: Tomcat: kick start

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top