Hi,

Thanks for improvments. I'm not very comfortable with dos and reading our .bat is always a bit painful (but instructive !) .

Michaël


Le 25/06/2018 à 14:25, edgar.sol...@web.de a écrit :
Mike,

generally elegant solution. i like it.

just added some changes in the next commit
1. replaced tabs w/ spaces
2. wrapped %JAVA% as it might contain special chars in path
3. changed the call:end to goto so it will end the batch instead of running 
further
4. indented printed messages for better readablility
5. added var ERROR to enable pause in end subroutine
6. added a JAVA_HOME stale warning
7. fixed wow64 not ending correctly

also discovered a bug when using JAVA_HOME="C:\Program Files 
(x86)\Java\jre1.8.0_xx" because of the parentheses. so i had to quote wrap more 
carefully.

..ede

On 25.06.2018 09:07, jump-pilot-svn--- via Jump-pilot-devel wrote:
Revision: 5897
           http://sourceforge.net/p/jump-pilot/code/5897
Author:   michaudm
Date:     2018-06-25 07:07:07 +0000 (Mon, 25 Jun 2018)
Log Message:
-----------
Modify slightly the way the windows .bat search for java

Modified Paths:
--------------
     core/trunk/ChangeLog
     core/trunk/scripts/oj_windows.bat

Modified: core/trunk/ChangeLog
===================================================================
--- core/trunk/ChangeLog        2018-06-22 14:11:24 UTC (rev 5896)
+++ core/trunk/ChangeLog        2018-06-25 07:07:07 UTC (rev 5897)
@@ -3,6 +3,9 @@
  # 2. make sure that lines break at 80 chars for constricted display situations
  #<-------------------------------- 80 chars 
---------------------------------->#
+2018-06-25
+  * Modify slightly the way the windows .bat search for java
+
  2018-06-11 Giuseppe Aruta. Raster profile plugin:
    * Plugin recognizes Layer unit.
    * Absolute or relative slope output

Modified: core/trunk/scripts/oj_windows.bat
===================================================================
--- core/trunk/scripts/oj_windows.bat   2018-06-22 14:11:24 UTC (rev 5896)
+++ core/trunk/scripts/oj_windows.bat   2018-06-25 07:07:07 UTC (rev 5897)
@@ -49,7 +49,11 @@
    rem --- default to javaw ---
    if "%JAVA_BIN%"=="" set JAVA_BIN=javaw
- rem --- search binary in path ---
+  rem --- if JAVA_HOME is defined and valid, use it ---
+  if NOT "%JAVA_HOME%"=="" set "JAVA=%JAVA_HOME%\bin\%JAVA_BIN%"
+  if exist "%JAVA%.exe" goto java_is_set
+
+  rem --- otherwise, search binary in path ---
    @for %%i in (%JAVA_BIN%.exe) do @if NOT "%%~$PATH:i"=="" set JAVA=%%~$PATH:i
rem --- we might be on amd64 having only x86 jre installed ---
@@ -63,10 +67,17 @@
rem --- if unset fall back to plain bin name, just in case ---
    if "%JAVA%"=="" set JAVA=%JAVA_BIN%
-
-  rem --- java home definition overwrites all ---
-  if NOT "%JAVA_HOME%"=="" set "JAVA=%JAVA_HOME%\bin\%JAVA_BIN%"
+ rem --- if %JAVA% is still not a valid java path, print an informative warning ---
+  if not exist %JAVA% (
+    echo WARNING : JAVA can not be found on your system
+       echo check that you have a valid JRE or JDK accessible from the system 
PATH or from the variable environment JAVA_HOME
+       pause
+       call:end
+  )
+
+rem -- we now have a valid java executable
+:java_is_set
  rem -- show java version (for debugging) --
  for %%F in ("%JAVA%") do set "dirname=%%~dpF"
  echo Using '%JAVA_BIN%' found in '%dirname%'


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Jump-pilot-devel mailing list
Jump-pilot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Jump-pilot-devel mailing list
Jump-pilot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Jump-pilot-devel mailing list
Jump-pilot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel

Reply via email to