[ 
https://issues.apache.org/jira/browse/GROOVY-6023?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15122338#comment-15122338
 ] 

David Cole commented on GROOVY-6023:
------------------------------------

I encountered this issue myself. I don't have any /../ in my JAVA_HOME, which 
is set to: JAVA_HOME=C:/Apps/Java/jdk1.8.0_66
on Windows.

The proposed solution using 'if exists' did correct my issue as well.

> ERROR: JAVA_HOME is set to an invalid directory
> -----------------------------------------------
>
>                 Key: GROOVY-6023
>                 URL: https://issues.apache.org/jira/browse/GROOVY-6023
>             Project: Groovy
>          Issue Type: Bug
>          Components: command line processing
>    Affects Versions: 2.1.1
>         Environment: Windows 7 x64
>            Reporter: Maxim Butov
>
> The problem takes place when JAVA_HOME contains "/../". For example:
> {code}
> set THIS_DIR=%~dp0.
> :: Resolve platform root dir
> set MB_HOME=%THIS_DIR%\..
> :: Resolve java home.
> set JAVA_HOME=%MB_HOME%\jdk-1.6.0_25-win64
> :: Resolve groovy home.
> set GROOVY_HOME=%MB_HOME%\groovy-2.1.1
> call "%GROOVY_HOME%\bin\groovy.bat" "%THIS_DIR%\mb.groovy" %*
> {code}
> In this case we have JAVA_HOME=C:\some\path\scripts\.\..\jdk-1.6.0_25-win64.
> In the subsequently called startGroovy.bat the lines:
> {code}
> @rem Validate JAVA_HOME
> %COMMAND_COM% /C DIR "%JAVA_HOME%" 2>&1 | %FIND_EXE% /I /C "%JAVA_HOME%" >nul
> if not errorlevel 1 goto valid_JAVA_HOME_DIR
> {code}
> give non-zero errorlevel, because the output of DIR command doesn't contain 
> "C:\some\path\scripts\.\..\jdk-1.6.0_25-win64", it actually contains 
> "C:\some\path\jdk-1.6.0_25-win64".
> The solution of the problem can be code like:
> {code}
> if exists "%JAVA_HOME%\bin\java.exe" ...
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to