XWiki Platform
  1. XWiki Platform
  2. XWIKI-12150

Windows installer fails to discover where java is located

    Details

    • Difficulty:
      Unknown
    • Documentation:
      N/A
    • Documentation in Release Notes:
      N/A
    • Similar issues:

      Description

      This is a regression introduced by XWIKI-10810

      This is what I get:

      Starting Jetty on port 8080, please wait...
      '"java"' is not recognized as an internal or external command,
      operable program or batch file.
      Press any key to continue . . .
      

      Now if change from:

      if not "%JAVA_HOME%" == "" (
        set JAVA_PATH=%JAVA_HOME\bin:java.exe
      ) else (
        for /f tokens^=2^ delims^=^" %%i in ('reg query HKEY_CLASSES_ROOT\jarfile\shell\open\command /ve') do set JAVAW_PATH=%%i
        set JAVA_PATH=%JAVAW_PATH:\javaw.exe=%\java.exe
        if "%JAVA_PATH%"=="" set JAVA_PATH=java
      )
      

      to

        for /f tokens^=2^ delims^=^" %%i in ('reg query HKEY_CLASSES_ROOT\jarfile\shell\open\command /ve') do set JAVAW_PATH=%%i
        set JAVA_PATH=%JAVAW_PATH:\javaw.exe=%\java.exe
        if "%JAVA_PATH%"=="" set JAVA_PATH=java
      

      then it works...

      Note that on my system JAVA_HOME is not defined.

        Issue Links

          Activity

          Hide
          Vincent Massol added a comment - - edited

          More info, if I write this it stills fails:

          for /f tokens^=2^ delims^=^" %%i in ('reg query HKEY_CLASSES_ROOT\jarfile\shell\open\command /ve') do set JAVAW_PATH=%%i
          if not "%JAVA_HOME%" == "" (
           echo YOYOYYO
           set JAVA_PATH=%JAVA_HOME\bin:java.exe
          ) else (
           set JAVA_PATH=%JAVAW_PATH:\javaw.exe=%\java.exe
           if "%JAVA_PATH%"=="" set JAVA_PATH=java
          )
          

          The error is: "\Java\jre7\bin\java.exe was unexpected at this time."

          But if I write this it works:

          for /f tokens^=2^ delims^=^" %%i in ('reg query HKEY_CLASSES_ROOT\jarfile\shell\open\command /ve') do set JAVAW_PATH=%%i
          set JAVA_PATH=%JAVAW_PATH:\javaw.exe=%\java.exe
          if not "%JAVA_HOME%" == "" (
           set JAVA_PATH=%JAVA_HOME\bin:java.exe
          ) else (
           if "%JAVA_PATH%"=="" set JAVA_PATH=java
          )
          

          I don't understand why ATM...

          Show
          Vincent Massol added a comment - - edited More info, if I write this it stills fails: for /f tokens^=2^ delims^=^" %%i in ('reg query HKEY_CLASSES_ROOT\jarfile\shell\open\command /ve') do set JAVAW_PATH=%%i if not "%JAVA_HOME%" == "" ( echo YOYOYYO set JAVA_PATH=%JAVA_HOME\bin:java.exe ) else ( set JAVA_PATH=%JAVAW_PATH:\javaw.exe=%\java.exe if "%JAVA_PATH%"=="" set JAVA_PATH=java ) The error is: "\Java\jre7\bin\java.exe was unexpected at this time." But if I write this it works: for /f tokens^=2^ delims^=^" %%i in ('reg query HKEY_CLASSES_ROOT\jarfile\shell\open\command /ve') do set JAVAW_PATH=%%i set JAVA_PATH=%JAVAW_PATH:\javaw.exe=%\java.exe if not "%JAVA_HOME%" == "" ( set JAVA_PATH=%JAVA_HOME\bin:java.exe ) else ( if "%JAVA_PATH%"=="" set JAVA_PATH=java ) I don't understand why ATM...
          Hide
          Vincent Massol added a comment -

          Thus a solution would probably to write the following but we need to understand why:

          REM Get javaw.exe from the latest properly installed JRE
          for /f tokens^=2^ delims^=^" %%i in ('reg query HKEY_CLASSES_ROOT\jarfile\shell\open\command /ve') do set JAVAW_PATH=%%i
          set JAVA_PATH=%JAVAW_PATH:\javaw.exe=%\java.exe
          if "%JAVA_PATH%"=="" set JAVA_PATH=java
          if not "%JAVA_HOME%" == "" set JAVA_PATH=%JAVA_HOME\bin:java.exe
          
          Show
          Vincent Massol added a comment - Thus a solution would probably to write the following but we need to understand why: REM Get javaw.exe from the latest properly installed JRE for /f tokens^=2^ delims^=^" %%i in ('reg query HKEY_CLASSES_ROOT\jarfile\shell\open\command /ve') do set JAVAW_PATH=%%i set JAVA_PATH=%JAVAW_PATH:\javaw.exe=%\java.exe if "%JAVA_PATH%"=="" set JAVA_PATH=java if not "%JAVA_HOME%" == "" set JAVA_PATH=%JAVA_HOME\bin:java.exe
          Hide
          Vincent Massol added a comment - - edited

          FTR, the following works in my test:

          REM Get javaw.exe from the latest properly installed JRE
          for /f tokens^=2^ delims^=^" %%i in ('reg query HKEY_CLASSES_ROOT\jarfile\shell\open\command /ve') do set JAVAW_PATH=%%i
          set JAVA_PATH=%JAVAW_PATH:\javaw.exe=%\java.exe
          if "%JAVA_PATH%"=="" set JAVA_PATH=java
          if not "%JAVA_HOME%" == "" set JAVA_PATH=%JAVA_HOME%\bin\java.exe
          
          Show
          Vincent Massol added a comment - - edited FTR, the following works in my test: REM Get javaw.exe from the latest properly installed JRE for /f tokens^=2^ delims^=^" %%i in ('reg query HKEY_CLASSES_ROOT\jarfile\shell\open\command /ve') do set JAVAW_PATH=%%i set JAVA_PATH=%JAVAW_PATH:\javaw.exe=%\java.exe if "%JAVA_PATH%"=="" set JAVA_PATH=java if not "%JAVA_HOME%" == "" set JAVA_PATH=%JAVA_HOME%\bin\java.exe
          Hide
          Vincent Massol added a comment -

          I'll wait for Manuel Smeria 's proposal on how to fix this issue and baring any I'll commit what's in the comment above in 1 or 2 days.

          Show
          Vincent Massol added a comment - I'll wait for Manuel Smeria 's proposal on how to fix this issue and baring any I'll commit what's in the comment above in 1 or 2 days.
          Hide
          Vincent Massol added a comment -

          Committed the quick fix now so that it's in 7.1 but it would be good to understand why the IF/ELSE doesn't work since it's a better logic than the quick fix.

          Show
          Vincent Massol added a comment - Committed the quick fix now so that it's in 7.1 but it would be good to understand why the IF/ELSE doesn't work since it's a better logic than the quick fix.

            People

            • Assignee:
              Vincent Massol
              Reporter:
              Vincent Massol
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: