Uploaded image for project: 'Jira Data Center'
  1. Jira Data Center
  2. JRASERVER-59656

config.bat script does not correctly detect Java version on Windows

    XMLWordPrintable

Details

    Description

      Summary

      In windows running the config.bat presents an error of:

      Wrong JVM version!  JIRA requires at least 1.8 to run.
      

      This error is presented even though JAVA_HOME is correctly set and can be verified by typing in java -version at a command prompt. Doing so returns : Java Version "1.8.0_060"

      JAVA_HOME is set as : c:\Program Files\Java\jdk1.8.0_60
      results of 'set JAVA_Home' command: c:\Program Files\Java\jdk1.8.0_60

      Environment

      Windows

      Steps to Reproduce

      Run config.bat from command line in windows
      Note previously mentioned error, config tool does not run

      Expected Results

      Correct installed java version is detected an config tool runs.

      Actual Results

      The below error is shown in command prompt window

      Wrong JVM version!  JIRA requires at least 1.8 to run.
      ...
      

      Notes

      The config.bat file references the check-java.bat file which by default is:

       
       
      @ECHO OFF
      
      setlocal
      
      rem
      rem check for correct java version by parsing out put of java -version
      rem we expect first line to be in format "java version 1.8.0" and assert that minor version number will be 8 or higher
      rem
      
      set EXPECTED_JAVA_VERSION=8
      
      for /f "tokens=2 delims=." %%a in ('%_EXECJAVA% -version 2^>^&1') do (
         set VERSION=%%a
         goto loaded_version
      )
      goto wrong_version
      
      :loaded_version
      IF %VERSION% LSS %EXPECTED_JAVA_VERSION% goto wrong_version
      
      goto:eof
      
      :wrong_version
      echo %%a
      echo *******************************************************************************
      echo *******      Wrong JVM version! JIRA requires at least 1.8 to run.      *******
      echo *******************************************************************************
      exit /b 1
      

      This does not produce a valid return even though the correct java version is installed.

      Workaround

      I was able to workaround the issue by modifying the check-java.bat file to the following:

      @ECHO OFF
      
      setlocal
      
      rem
      rem check for correct java version by parsing out put of java -version
      rem we expect first line to be in format "java version 1.8.0" and assert that minor version number will be 8 or higher
      rem
      
      set EXPECTED_JAVA_VERSION=8
      
      for /f "tokens=3" %%g in ('java -version 2^>^&1 ^| findstr /i "version"') do (
          set JAVAVER=%%g
      )
      set JAVAVER=%JAVAVER:"=%
      
      
      for /f "delims=. tokens=2" %%v in ("%JAVAVER%") do (
         
         set JAVA=%%v
         goto loaded_version
      )
      
      :loaded_version
      IF %JAVA% LSS %EXPECTED_JAVA_VERSION% goto wrong_version
      
      
      goto:eof
      
      :wrong_version
      echo *******************************************************************************
      echo *******      Wrong JVM version! JIRA requires at least 1.8 to run.      *******
      echo *******************************************************************************
      exit /b 1
      

      Attachments

        Issue Links

          Activity

            People

              655e9ad13484 Daria Misiowiec
              schristopher@atlassian.com ScottC
              Votes:
              2 Vote for this issue
              Watchers:
              23 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: