Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6640777
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:42:44+00:00 2026-05-25T23:42:44+00:00

I wrote the below batch script which asks for a JAVA_HOME path if its

  • 0

I wrote the below batch script which asks for a JAVA_HOME path if its not present in environment, and then it verifies the java version. but before identifying java version it should also check whether java is present in the path (can be executed) or not. Please help me figure out if java -version can be executed or not and display proper message

@echo off
setlocal

set VERSION5="1.5"

IF "%JAVA_HOME%" == "" (
echo Enter path to JAVA_HOME: 
set /p JAVA_HOME=
goto check_java_version
) ELSE (
echo Using %JAVA_HOME%
goto check_java_version
)


:check_java_version
 for /f "tokens=3" %%g in ('%JAVA_HOME%\jre\bin\java -version 2^>^&1 ^| findstr /i "version"') do (

set JAVAVER=%%g
)

set JAVAVER=%JAVAVER:"=%

set JAVAVER=%JAVAVER:java version =%

for /f "delims=. tokens=1-3" %%v in ("%JAVAVER%") do (
set VER=%%w
)

if not "%VER%" GEQ "5" goto wrong_version
set JAVA_BIN=%JAVA_HOME%\jre\bin
goto correct_java_version


:correct_java_version
REM echo JAVA Version is ok.
set JAVA_LIB=%cd%/lib

%JAVA_BIN%/java -cp %JAVA_LIB%/csm-runtime-1.0.jar;%JAVA_LIB%/groovy-all-1.8.1.jar;%JAVA_LIB%/commons-beanutils-1.8.3.jar;%JAVA_LIB%/csm-dbutil-1.0.jar;%JAVA_LIB%/commons-exec-1.1.jar;%JAVA_LIB%/log4j-1.2.8.jar;%JAVA_LIB%/commons-cli-1.2.jar -Dlog4j.configuration=com/ABC/csm/log4j.xml -Dendorsed_plugins_dir=./plugins    com.ABC.csm.CSMMain %* 
goto end_java_version

:wrong_version
echo Current JDK Version %VER%
echo Expected JDK %VERSION5% or greater. Please fix your SSATOP and try again.
goto end_java_version

:no_java
echo No JDK found in %JAVA_HOME%.
goto wrong_version

:end_java_version
endlocal

1 of the examples of invalid condition would be, instead of providing JAVA_HOME i.e., e:\csm\java I gave it as e:\csm\java\jre\bin which in this case should display proper error message that please provide a JAVA_HOME path

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T23:42:45+00:00Added an answer on May 25, 2026 at 11:42 pm

    To check the existence of a program in the PATH, windows batch provides the ~%PATH: option of the SET command. See HELP CALL or HELP FOR.

    Use this piece of code as a starting point.

    :ProgInPath
    set PROG=%~$PATH:1
    goto :eof
    

    and use it like this

    call :ProgInPath java.exe
    IF "%PROG%" == "" (
      echo Java.exe not found
    ) else (
      echo. %PROG%
    )
    

    in this example, if java.exe is in the PATH, it echoes its complete filespec.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have wrote the code below which was taken from Java How to program
Below is the code which I wrote to display a tooltip content. As the
I have wrote below code. import java.io.*; class Test { public static void main(String
I am having a very interesting problem. The script I wrote below works, but
I am struggling to write a batch script which can read a CSV file
Is the function I wrote below enough to preload images in most, if not
I have to perform async execution, and i have wrote the below code var
I wrote the code below : 1. MyClass[] origArr=new MyClass[3]; 2. MyClass[] arr1; 3.
So I wrote the code below: jQuery('#contentWrapper').delegate(.addButton, click, function(){ addRow(jQuery(this)); }); function addRow(thisButton){ var
Below is some jQuery code the i wrote to make a simple animation. However

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.