for /f tokens^=2-5^ delims^=.-_^" %j in ('java -fullversion 2^>^&1') do @set "jver=%j%k%l%m"
This will save the java version in the jver variable and as an integer And you can use it to compare .EG
if %jver% LSS 16000 echo not supported version
. You can use the larger version by deleting% k and% l and% m. This is the command line version.
For .bat use this:
@echo off PATH %PATH%;%JAVA_HOME%\bin\ for /f tokens^=2-5^ delims^=.-_^" %%j in ('java -fullversion 2^>^&1') do set "jver=%%j%%k%%l%%m"
According to my tests, this is the fastest way to get the Java version from bat (since it uses only internal commands and not external like FIND , FINDSTR and does not use GOTO , which can also slow down the script). Some JDK providers do not support the -fullversion switch or their implementation is not the same as in Oracle Oracle (it is better to avoid them).
npocmaka
source share