0

I am not quite familiar with the Command Prompt syntax but I have learned a few. Please help. I need to provide a cmd script that will check the existing Java version first (because my application requires jdk7). My idea is, it would only run if it passes the required version of Java and Play! If not, it should prompt the required version and the application won't run. I am trying this cmd file:

@Echo off
Echo Checking Java Version.
if "javac -version" == "1.7.0_51" (
    Echo JDK7 Found.
    Echo Checking Play! Version.
    play
    if (%play-version% == "2.2.2") (
        Echo "Play! Framework Found."
            run
        )
    ELSE (
        Echo Play! Version 2.2.2 Required.
    )
) ELSE ( 
    Echo JDK 1.7 Required.
)

Please please help. I really have minimal ideas regarding cmd codes. Thank you!

  • possible duplicate of [Get java version from batch file](http://stackoverflow.com/questions/17714681/get-java-version-from-batch-file) – DavidPostill Jul 25 '14 at 10:14

1 Answers1

0

You can try the following code segment. It only shows how to check the java version. I am not familiar with Play.. You can do the necessary check for Play version inside the if condition with "YOUR_SUPPORTED_JAVA_VERSION"

if type -p java; then
    echo found java executable in PATH
   _java=java
fi
if [[ "$_java" ]]; then
    version=$("$_java" -version 2>&1 | awk -F '"' '/version/ {print $2}')
    echo version "$version"
    if [[ "$version" > "YOUR_SUPPORTED_JAVA_VERSION" ]]; then
       echo SUPPORTED_VERSION
    else
       echo NOT_SUPPORTED_VERSION
    fi
fi
dgm
  • 2,287
  • 1
  • 23
  • 27