How to fix this .bat file

H

HS1

Hello

To install a java application, I have to run a run.bat file. When I run,
there is a message in Dos window

"JAVA_HOME is not set.
Set JAVA_HOME to the directory of your local JDK to avoid this message."

I check this run.bat file and found that there is the below code in this
file

----------------------------------
:FOUND_RUN_JAR

if not "%JAVA_HOME%" == "" goto ADD_APPLICATIONS

set JAVA=java

echo JAVA_HOME is not set.
echo Set JAVA_HOME to the directory of your local JDK to avoid this message.
goto SKIP_TOOLS

:ADD_APPLICATIONS

set JAVA=%JAVA_HOME%\bin\java

if exist "%JAVA_HOME%\lib\tools.jar" goto SKIP_TOOLS
echo Could not locate %JAVA_HOME%\lib\tools.jar. Unexpected results may
occur.
echo Make sure that JAVA_HOME points to a JDK.
 
G

G Winstanley

Hello

To install a java application, I have to run a run.bat file. When I run,
there is a message in Dos window

"JAVA_HOME is not set.
Set JAVA_HOME to the directory of your local JDK to avoid this message."

I check this run.bat file and found that there is the below code in this
file

----------------------------------
:FOUND_RUN_JAR

if not "%JAVA_HOME%" == "" goto ADD_APPLICATIONS

set JAVA=java

echo JAVA_HOME is not set.
echo Set JAVA_HOME to the directory of your local JDK to avoid this message.
goto SKIP_TOOLS

:ADD_APPLICATIONS

set JAVA=%JAVA_HOME%\bin\java

if exist "%JAVA_HOME%\lib\tools.jar" goto SKIP_TOOLS
echo Could not locate %JAVA_HOME%\lib\tools.jar. Unexpected results may
occur.
echo Make sure that JAVA_HOME points to a JDK.

----------------------------

Could you please tell me how to fix this
Many thanks
S.Hoa

Check the documentation for "batch files".

Basically it is expecting the JAVA_HOME environment variable to be set to
the JDK/JRE root directory (e.g. C:\Program Files\Java\jdk1.5.0). Either
way, it uses the JAVA variable to allocate the command it should issue to
invoke the Java Runtime:

Either
set JAVA=java
or
set JAVA=%JAVA_HOME%\bin\java

depending whether JAVA_HOME is set or not. The problem seems to arise
because if the JAVA_HOME variable is not set the script tell the user then
jumps to the label SKIP_TOOLS. We cannot see SKIP_TOOLS from the above
snippet, but presumably it exits the script. My assumption is that it
shouldn't exit the script, but instead invoke the Java Runtime using
something like:
%JAVA% <classname>
where <classname> is a fully-qualified classname.

Stan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,588
Members
45,095
Latest member
EmiliaAlfo

Latest Threads

Top