I am trying to install sikuli v1.0.1 on a new computer. I have installed Sikuli on other machines before and it works like a charm.
This time however, sikuli won't start the setup.
As usual, I copied the setup-file into a folder on the desktop and then executed the file to receive the "runSetup" file and the log, which worked just fine.
However, when I execute the runSetup file, the cmd-window briefly appears and closes almost instantly with no further window opening as I am used to...
Does anyone have an idea to solve the issue?
I am trying to install on a windows 7, 64bit (just like all other computers, where I have worked with Sikuli)
Thanks in advance!
Short update:
I have just tried running the setup file from the cmd prompt but get the following error when doin so:
+++ Java not found in standard places C:\Program Files or C:\Program Files (x86)
+++ JAVA_HOME not specified
+++ ended with some errors
However, A java folder exists in the mentioned directory...
You need Java as wel as JDK installed on your computer.
If you right click on the .cmd file and select "Edit" you can see what he is trying. It will give you an idea about what is missing from your computer.
I think you don't have jre6 or jre7 installed.
EDIT
Okey, I was just installing this on my new computer as well. And I had the same problem. It also seems like that Oracle has released a new version. The old version will from March 2015 not be supported anymore. So... I decided to keep the latest Java version and to adjust the "runSetup.cmd" and "runIDE.cmd" to recognize the latest Java version.
I will post the adjustment here, so maybe other people can also use them.
For making this clear. If you go to "C:\Program Files (x86)\Java" I have here the directory "jre1.8.0_40".
I also made the adjustment for the people that have java installed in "C:\Program Files". I just haven't tested it. But I think it will work because it is exactly the same.
These are the adjusted files that should work:
runSetup.cmd
#echo off
SETLOCAL
set SIKULIX_HOME=%~dp0
set PARMS=-Xms64M -Xmx512M -Dfile.encoding=UTF-8
if not defined JAVA_HOME goto CHECKJAVA
IF EXIST "%JAVA_HOME%\bin\java.exe" goto JAVA_OK
echo +++ JAVA_HOME specified but not useable %JAVA_HOME%
echo +++ looking for Java in standard places
:CHECKJAVA
set PROGRAMS=%ProgramFiles%
if defined ProgramFiles(x86) set PROGRAMS32=%ProgramFiles(x86)%
IF not EXIST "%PROGRAMS%\Java\jre1.8.0_40" goto JAVA7
set JAVA_HOME=%PROGRAMS%\Java\jre1.8.0_40
goto JAVA_OK
:JAVA7
IF not EXIST "%PROGRAMS%\Java\jre7" goto JAVA6
set JAVA_HOME=%PROGRAMS%\Java\jre7
goto JAVA_OK
:JAVA6
IF not EXIST "%PROGRAMS%\Java\jre6" goto JAVANO
set JAVA_HOME=%PROGRAMS%\Java\jre6
goto JAVA_OK
:JAVANO
if not defined %PROGRAMS32% goto JAVANO32
IF not EXIST "%PROGRAMS32%\Java\jre1.8.0_40" goto JAVA7
set JAVA_HOME=%PROGRAMS32%\Java\jre1.8.0_40
goto JAVA_OK
:JAVA7
IF not EXIST "%PROGRAMS32%\Java\jre7" goto JAVA6
set JAVA_HOME=%PROGRAMS32%\Java\jre7
goto JAVA_OK
:JAVA6
IF not EXIST "%PROGRAMS32%\Java\jre6" goto JAVANO32
set JAVA_HOME=%PROGRAMS32%\Java\jre6
goto JAVA_OK
:JAVANO32
echo +++ Java not found in standard places %PROGRAMS% or %PROGRAMS32%
echo +++ JAVA_HOME not specified
goto STOPIT
:JAVA_OK
echo +++ running this Java
"%JAVA_HOME%\bin\java.exe" -version
PATH=%SIKULIX_HOME%libs;%PATH%
echo +++ trying to start Sikuli Setup in %SIKULIX_HOME%
"%JAVA_HOME%\bin\java.exe" %PARMS% -jar "%SIKULIX_HOME%sikuli-setup.jar" %*
GOTO FINALLY
:STOPIT
echo.+++ ended with some errors
:FINALLY
ENDLOCAL
runIDE.cmd
#echo off
SETLOCAL
set SIKULIX_HOME=%~dp0
set PARMS=-Xms64M -Xmx512M -Dfile.encoding=UTF-8 -Dsikuli.FromCommandLine
if not defined JAVA_HOME goto CHECKJAVA
IF EXIST "%JAVA_HOME%\bin\java.exe" goto JAVA_OK
echo +++ JAVA_HOME specified but not useable %JAVA_HOME%
echo +++ looking for Java in standard places
:CHECKJAVA
set PROGRAMS=%ProgramFiles%
if defined ProgramFiles(x86) set PROGRAMS32=%ProgramFiles(x86)%
IF not EXIST "%PROGRAMS%\Java\jre1.8.0_40" goto JAVA7
set JAVA_HOME=%PROGRAMS%\Java\jre1.8.0_40
goto JAVA_OK
:JAVA7
IF not EXIST "%PROGRAMS%\Java\jre7" goto JAVA6
set JAVA_HOME=%PROGRAMS%\Java\jre7
goto JAVA_OK
:JAVA6
IF not EXIST "%PROGRAMS%\Java\jre6" goto JAVANO
set JAVA_HOME=%PROGRAMS%\Java\jre6
goto JAVA_OK
:JAVANO
if not defined %PROGRAMS32% goto JAVANO32
IF not EXIST "%PROGRAMS32%\Java\jre1.8.0_40" goto JAVA7
set JAVA_HOME=%PROGRAMS32%\Java\jre1.8.0_40
goto JAVA_OK
:JAVA7
IF not EXIST "%PROGRAMS32%\Java\jre7" goto JAVA6
set JAVA_HOME=%PROGRAMS32%\Java\jre7
goto JAVA_OK
:JAVA6
IF not EXIST "%PROGRAMS32%\Java\jre6" goto JAVANO32
set JAVA_HOME=%PROGRAMS32%\Java\jre6
goto JAVA_OK
:JAVANO32
echo +++ Java not found in standard places %PROGRAMS% or %PROGRAMS32%
echo +++ JAVA_HOME not specified
goto STOPIT
:JAVA_OK
echo +++ running this Java
set SIKULI_COMMAND=%*
"%JAVA_HOME%\bin\java.exe" -version
PATH=%SIKULIX_HOME%libs;%PATH%
echo +++ trying to start Sikuli IDE
echo +++ using: %PARMS% -jar %SIKULIX_HOME%sikuli-ide.jar %SIKULI_COMMAND%
"%JAVA_HOME%\bin\java.exe" %PARMS% -jar "%SIKULIX_HOME%sikuli-ide.jar" %SIKULI_COMMAND%
GOTO FINALLY
:STOPIT
echo.+++ ended with some errors
:FINALLY
ENDLOCAL
If you still have problems with running "runSetup.cmd" you can also add "pause" (without quotes) below the file on an empty line. Then the command prompt will stay and you can read the error.
Related
I use an environment variable to define the path for Java so I can change what version of Java I'm using (.bat file is shown at the end of this post).
The whole thing hinges on creating a %JAVA_VERSION% environment variable and then using that in the path. This all works on my lap top. When I use %JAVA_VERSION% in the Path environment variable it is correctly resolved to the value of the environment variable as shown below.
However, when I do this on an AWS EC2 instance, the %JAVA_VERSION% variable is not resolved as shown below and running "java" at a cmd prompt does not work.
Is there a way to get this to work on the Windows Server (details of the server shown below)
This is the .bat file used to switch Java versions:
:: ---
::
:: SCRIPT TO SET JAVA VERSION
::
:: ---
#echo off
echo.
echo.
if "%~1"=="" goto error
if %1%==8 goto v8
if %1%==11 goto v11
echo Valid Input Is:
echo 8
echo 11
echo.
:v8
echo Setting Java Version to 1.8
set JAVA_VERSION=C:\_YES\tools\java\jdk1.8.0_261\bin
set JAVA_HOME="C:\_YES\tools\java\jdk1.8.0_261\
setx JAVA_VERSION C:\_YES\tools\java\jdk1.8.0_261\bin
setx JAVA_HOME C:\_YES\tools\java\jdk1.8.0_261\
goto endif
:v11
echo Setting Java Version to 11.0.11
set JAVA_VERSION=C:\_YES\tools\java\jdk-11.0.11\bin
set JAVA_HOME="C:\_YES\tools\java\jdk-11.0.11\
setx JAVA_VERSION C:\_YES\tools\java\jdk-11.0.11\bin
setx JAVA_HOME C:\_YES\tools\java\jdk-11.0.11\
goto endif
:v1.17
echo Setting Java Version to 1.17
set JAVA_VERSION=C:\program_files\Java\jdk-17.0.2\bin
set JAVA_HOME=C:\program_files\Java\jdk-17.0.2\
setx JAVA_VERSION C:\program_files\Java\jdk-17.0.2\bin
setx JAVA_HOME C:\program_files\Java\jdk-17.0.2\
goto endif
:error
echo ! ! ! JAVA VERSION NOT SET ! ! !
echo Java version must be 8 or 11
goto endif
goto end
:endif
set path=%JAVA_VERSION%;%PATH%
:end
echo Current JAVA_VERSION is %JAVA_VERSION%
#echo on
java -version
#echo off
echo.
echo.
echo Done.
echo.
echo.
This issue was caused by a quote character (") at the beginning of the JAVA_VERSION variable when the error was seen. Similar to what was occurring in ant error "The syntax of the command is incorrect." on running ant.bat.
I need to find the specific location of java 64-bit on a windows machine. I thought about using where java to find all possible locations. In the next step I would need to isolate the proper location which starts with: C:\Program Files\Java\... and then execute the command as following:
cmd /K %var% -jar %~dp0XYZ.jar
Is this the proper way to find the java path which might change over time? If yes, how can I get the path from where into a variable?
For the output of where assume this:
C:\Program Files (x86)\Common Files\Oracle\Java\javapath\java.exe
C:\Program Files\Java\jdk1.8.0_144\bin\java.exe
C:\Program Files\Java\jdk1.8.0_144\jre\bin\java.exe
It wouldn't matter if it takes second or third result, as both are 64 bit in this case. But as I can't guarantee that output, the only way to identify the 64-bit version is with C:\Program Files\Java\
The following bat script (commented for explanation) should do the trick:
#ECHO OFF
rem SETLOCAL EnableExtensions DisableDelayedExpansion
set "_flagexe64=:\Program Files\Java\"
set "_javaexe64="
for /f "delims=" %%G in ('where java.exe') do (
rem next two lines for debugging only
echo checking "%%~G"
"%%~G" -version
if not defined _javaexe64 (
set "_javaexe64=%%~G"
call :check64
)
)
rem final check
if not defined _javaexe64 (
1>&2 echo sorry, no java.exe found under "%_flagexe64%"
goto :eof
)
rem java.exe found:
echo "%_javaexe64%"
goto :eof
:check64
call set "_aux=%%_javaexe64:%_flagexe64%=%%"
if "%_aux%" == "%_javaexe64%" set "_javaexe64="
goto :eof
I am really new in WSO2 and are having some little problems to carry on with my project.
I do what the tutorials:
www.docs.wso2.com/display/EI600/Installing+as+a+Windows+Service
www.docs.wso2.com/display/Carbon420/Installing+as+a+Windows+Service
Teaches, and create de windows service. I start it and close the command prompts with the 'runConsole.bat' command, the link continue working in the first 10 seconds, later it stop's. How can i solve it?
If anyone could help me i would stay quite grateful.
Thank you everyone.
Add a loop. This will make it go over and over until you click the X in the top right side of your screen. I would recommend just clicking the - instead.
:loop
Follow the batch code as asked.
#echo off
REM ---------------------------------------------------------------------------
REM Copyright 2005-2009 WSO2, Inc. http://www.wso2.org
REM
REM Licensed under the Apache License, Version 2.0 (the "License");
REM you may not use this file except in compliance with the License.
REM You may obtain a copy of the License at
REM
REM http://www.apache.org/licenses/LICENSE-2.0
REM
REM Unless required by applicable law or agreed to in writing, software
REM distributed under the License is distributed on an "AS IS" BASIS,
REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
REM See the License for the specific language governing permissions and
REM limitations under the License.
rem ---------------------------------------------------------------------------
rem Main Script for WSO2 Carbon
rem
rem Environment Variable Prequisites
rem
rem CARBON_HOME Home of CARBON installation. If not set I will try
rem to figure it out.
rem
rem JAVA_HOME Must point at your Java Development Kit installation.
rem
rem JAVA_OPTS (Optional) Java runtime options used when the commands
rem is executed.
rem ---------------------------------------------------------------------------
rem ----- if JAVA_HOME is not set we're not happy ------------------------------
:checkJava
if "%JAVA_HOME%" == "" goto noJavaHome
if not exist "%JAVA_HOME%\bin\java.exe" goto noJavaHome
goto checkServer
:noJavaHome
echo "You must set the JAVA_HOME variable before running CARBON."
goto end
rem ----- Only set CARBON_HOME if not already set ----------------------------
:checkServer
rem %~sdp0 is expanded pathname of the current script under NT with spaces in the path removed
if "%CARBON_HOME%"=="" set CARBON_HOME=%~sdp0..
SET curDrive=%cd:~0,1%
SET wsasDrive=%CARBON_HOME:~0,1%
if not "%curDrive%" == "%wsasDrive%" %wsasDrive%:
rem find CARBON_HOME if it does not exist due to either an invalid value passed
rem by the user or the %0 problem on Windows 9x
if not exist "%CARBON_HOME%\bin\version.txt" goto noServerHome
set AXIS2_HOME=%CARBON_HOME%
goto updateClasspath
:noServerHome
echo CARBON_HOME is set incorrectly or CARBON could not be located. Please set CARBON_HOME.
goto end
rem ----- update classpath -----------------------------------------------------
:updateClasspath
setlocal EnableDelayedExpansion
cd %CARBON_HOME%
set CARBON_CLASSPATH=
FOR %%C in ("%CARBON_HOME%\bin\*.jar") DO set CARBON_CLASSPATH=!CARBON_CLASSPATH!;".\bin\%%~nC%%~xC"
set CARBON_CLASSPATH="%JAVA_HOME%\lib\tools.jar";%CARBON_CLASSPATH%;
FOR %%D in ("%CARBON_HOME%\lib\commons-lang*.jar") DO set CARBON_CLASSPATH=!CARBON_CLASSPATH!;".\lib\%%~nD%%~xD"
rem ----- Process the input command -------------------------------------------
rem Slurp the command line arguments. This loop allows for an unlimited number
rem of arguments (up to the command line limit, anyway).
:setupArgs
if ""%1""=="""" goto doneStart
if ""%1""==""-run"" goto commandLifecycle
if ""%1""==""--run"" goto commandLifecycle
if ""%1""==""run"" goto commandLifecycle
if ""%1""==""-restart"" goto commandLifecycle
if ""%1""==""--restart"" goto commandLifecycle
if ""%1""==""restart"" goto commandLifecycle
if ""%1""==""debug"" goto commandDebug
if ""%1""==""-debug"" goto commandDebug
if ""%1""==""--debug"" goto commandDebug
if ""%1""==""version"" goto commandVersion
if ""%1""==""-version"" goto commandVersion
if ""%1""==""--version"" goto commandVersion
shift
goto setupArgs
rem ----- commandVersion -------------------------------------------------------
:commandVersion
shift
type "%CARBON_HOME%\bin\version.txt"
type "%CARBON_HOME%\bin\wso2carbon-version.txt"
goto end
rem ----- commandDebug ---------------------------------------------------------
:commandDebug
shift
set DEBUG_PORT=%1
if "%DEBUG_PORT%"=="" goto noDebugPort
if not "%JAVA_OPTS%"=="" echo Warning !!!. User specified JAVA_OPTS will be ignored, once you give the --debug option.
set JAVA_OPTS=-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=%DEBUG_PORT%
echo Please start the remote debugging client to continue...
goto findJdk
:noDebugPort
echo Please specify the debug port after the --debug option
goto end
rem ----- commandLifecycle -----------------------------------------------------
:commandLifecycle
goto findJdk
:doneStart
if "%OS%"=="Windows_NT" #setlocal
if "%OS%"=="WINNT" #setlocal
rem ---------- Handle the SSL Issue with proper JDK version --------------------
rem find the version of the jdk
:findJdk
set CMD=RUN %*
:checkJdk17
"%JAVA_HOME%\bin\java" -version 2>&1 | findstr /r "1.[7|8]" >NUL
IF ERRORLEVEL 1 goto unknownJdk
goto jdk17
:unknownJdk
echo Starting WSO2 Carbon (in unsupported JDK)
echo [ERROR] CARBON is supported only on JDK 1.7 and 1.8
goto jdk17
:jdk17
goto runServer
rem ----------------- Execute The Requested Command ----------------------------
:runServer
cd %CARBON_HOME%
rem ------------------ Remove tmp folder on startup -----------------------------
set TMP_DIR=%CARBON_HOME%\tmp
cd "%TMP_DIR%"
del *.* /s /q > nul
FOR /d %%G in ("*.*") DO rmdir %%G /s /q
cd ..
rem ---------- Add jars to classpath ----------------
set CARBON_CLASSPATH=.\lib;%CARBON_CLASSPATH%
set JAVA_ENDORSED=".\lib\endorsed";"%JAVA_HOME%\jre\lib\endorsed";"%JAVA_HOME%\lib\endorsed"
set CMD_LINE_ARGS=-Xbootclasspath/a:%CARBON_XBOOTCLASSPATH% -Xms256m -Xmx1024m -XX:MaxPermSize=256m -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath="%CARBON_HOME%\repository\logs\heap-dump.hprof" -Dcom.sun.management.jmxremote -classpath %CARBON_CLASSPATH% %JAVA_OPTS% -Djava.endorsed.dirs=%JAVA_ENDORSED% -Dcarbon.registry.root=/ -Dcarbon.home="%CARBON_HOME%" -Dwso2.server.standalone=true -Djava.command="%JAVA_HOME%\bin\java" -Djava.opts="%JAVA_OPTS%" -Djava.io.tmpdir="%CARBON_HOME%\tmp" -Dcatalina.base="%CARBON_HOME%\lib\tomcat" -Dwso2.carbon.xml=%CARBON_HOME%\repository\conf\carbon.xml -Dwso2.registry.xml="%CARBON_HOME%\repository\conf\registry.xml" -Dwso2.user.mgt.xml="%CARBON_HOME%\repository\conf\user-mgt.xml" -Dwso2.transports.xml="%CARBON_HOME%\repository\conf\mgt-transports.xml" -Djava.util.logging.config.file="%CARBON_HOME%\repository\conf\etc\logging-bridge.properties" -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Dcarbon.config.dir.path="%CARBON_HOME%\repository\conf" -Dcomponents.repo="%CARBON_HOME%\repository\components" -Dconf.location="%CARBON_HOME%\repository\conf" -Dcom.atomikos.icatch.file="%CARBON_HOME%\lib\transactions.properties" -Dcom.atomikos.icatch.hide_init_file_path="true" -Dorg.apache.jasper.compiler.Parser.STRICT_QUOTE_ESCAPING=false -Dorg.apache.jasper.runtime.BodyContentImpl.LIMIT_BUFFER=true -Dcom.sun.jndi.ldap.connect.pool.authentication=simple -Dcom.sun.jndi.ldap.connect.pool.timeout=3000 -Dorg.terracotta.quartz.skipUpdateCheck=true -Dcarbon.classpath=%CARBON_CLASSPATH% -Dfile.encoding=UTF8
:runJava
echo JAVA_HOME environment variable is set to %JAVA_HOME%
echo CARBON_HOME environment variable is set to %CARBON_HOME%
"%JAVA_HOME%\bin\java" %CMD_LINE_ARGS% org.wso2.carbon.bootstrap.Bootstrap %CMD%
if "%ERRORLEVEL%"=="121" goto runJava
:end
goto endlocal
:endlocal
:END
Thank you everyone from the help.
I was able to solve my problem. After some tries oddly the project worked. I think that 2 things was confusing me. The first is that when you start the project, you have a good delay to start the url, something between 5 and 10 minutes. The second is sometimes the service stop, if you are running another one of the wso2.
But after repeat sometimes, i understood the standard way to run the services. First you have to prepare and run the service of EI600, wait until work and after run the other service, and, again, wait until work.
Thank you everyone from the help.
I'm a MR tool admin I need a batch script to satisfy the below requirements
It must check whether Java home is set in Computer > properties (right click) > Advanced system settings > Advanced > Environment Variables.
If Java home is available it needs to display "Java home is available" else "Java home is not available".
It must check the java version using and if it is greater than 1.6.495 it must display "Java version is too high" else "Java version is compatible".
Currently I'm using a script as given below...
Can anyone please please help for making the above script?
#echo off
IF "%JAVA_HOME%" == "" (
echo Enter path to JAVA_HOME:
set /p JAVA_HOME=
) ELSE (
echo %JAVA_HOME%
)
Give this a whirl ...
I wasn't quite sure what you mean by "java home is available". The script checks that the directory pointed to by %JAVA_HOME% contains a bin\java.exe.
The tricky bit is getting the version. I took the output of java -version and used FIND to pick up the first line which is something like java version "1.7.0_55" on my system. java -version writes this to stderr rather than stdout, hence the error redirect (2>& 1 redirects error output to standard output) before piping to FIND. That mess is then redirected into a temp file. Then I used a SET /p with input redirected from the temp to put that output into a variable.
#echo off
SETLOCAL
SET TEMPFILE=%TEMP%\tmpfile
IF "%JAVA_HOME%" == "" (
echo Enter path to JAVA_HOME:
set /p JAVA_HOME=
) ELSE (
echo JAVA_HOME = %JAVA_HOME%
)
IF EXIST "%JAVA_HOME%\bin\java.exe" (
ECHO Java home is available
) ELSE ECHO Java home is not available
"%JAVA_HOME%\bin\java" -version 2>& 1 | FIND "java version" > %TEMPFILE%
SET /p VERSIONSTRING= < %TEMPFILE%
DEL %TEMPFILE%
SET MAJORVERSION=%VERSIONSTRING:~14,1%
SET MINORVERSION=%VERSIONSTRING:~16,1%
SET UPDATEVERSION=%VERSIONSTRING:~20,-1%
IF %MAJORVERSION% GTR 1 GOTO TOOHIGH
IF %MINORVERSION% GTR 6 GOTO TOOHIGH
IF %UPDATEVERSION% GTR 495 GOTO TOOHIGH
ECHO Java version is compatible.
GOTO EXIT
:TOOHIGH
ECHO Java version is too high.
:EXIT
ENDLOCAL
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
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.
I used the below snippet and it solved my problem
:check_java_existence
IF EXIST %JAVA_HOME%\jre\bin\java.exe (
echo java exists
) ELSE (
echo java does not exists
)