Changeset 2362862

Nov 9, 2012 11:53:02 PM (8 years ago)
kytv <kytv@…>

eepget: If java binary is not found, try to determine where java.exe is located.

In my testing:
32 bit Windows (and, of course, 32 bit JRE) = Java added to the PATH
64 bit Windows and 64 bit JRE = Java added to the PATH
64 bit Windows and 32 bit JRE = Java *not* added to the PATH.

So…with this check-in:

  • If the environment variable JAVA is set in the script, we'll use that manually specified Java. We will not look in the registry, but we'll check to make sure that the binary exists.
  • If Java is found in the system path, we'll use it instead. We will not look in the registry.
  • If the variable is not set manually and Java is not in the system path we'll look in the registry to find the java binary.

I've tested this in Windows XP, Vista, and 7 but it should work in any supported version
of Windows.

2 edited


  • history.txt

    rf287ed4 r2362862  
     12012-11-10 kytv
     2* eepget: Add logic to figure out the path to java.exe (java isn't always added to the system path
     3  in Windows) (ticket #769)
    152012-11-05 zzz
    26 * Console:
  • installer/resources/eepget.bat

    rf287ed4 r2362862  
    11@echo off
     4:: This should have been changed by the installer
    3 java -cp "%_I2PHOME%\lib\i2p.jar" net.i2p.util.EepGet %1 %2 %3 %4 %5
     8:: In case the autodetection fails or a specific Java binary is needed,
     9:: uncomment the next line and set the full path to "java.exe"
     11REM set JAVA=
     14:: If we find Java in the path, or a specific Java binary was set, let's use
     15:: it instead of figuring it out ourselves.
     17if defined JAVA (
     18    goto eepget
     19) else (
     20    for %%I in (java.exe) do set JAVA=%%~$PATH:I
     23:: Does "elif" exist in Windows? It doesn't seem to...
     25if defined JAVA GOTO eepget
     28:: We should only end up here if Java isn't in the path
     30setlocal ENABLEEXTENSIONS
     31set KEY1="HKLM\SOFTWARE\JavaSoft\Java Runtime Environment"
     32set KEY2="HKLM\SOFTWARE\Wow6432Node\JavaSoft\Java Runtime Environment"
     33set VALUE_NAME=CurrentVersion
     36:: The key specified in the KEY1 variable should exist on 32bit windows
     37:: and 64bit Windows with a 64bit JRE.
     39:: The key specified in KEY2 will be used on a 64bit Windows with a 32-bit JRE.
     41reg query %KEY1% 2>nul && set KEY_NAME=%KEY1% || set KEY_NAME=%KEY2%
     44:: Get the current version from the registry
     46FOR /F "tokens=2,*" %%A IN ('REG QUERY %KEY_NAME% /v %VALUE_NAME% 2^>nul') DO (
     47    set VersionValue=%%B
     51:: Since we didn't find the registry keys (and JAVA wasn't set in this script),
     52:: we'll quit.
     54if not defined VersionValue (
     55    @echo Unable to find %KEY_NAME%\%VALUE_NAME% in the registry.
     56    @echo Please edit this script and manually set the variable JAVA.
     57    goto end
     60set JAVA_CURRENT=%KEY_NAME%\%VersionValue%
     61set J_HOME=JavaHome
     64:: Get the Java Home
     66FOR /F "tokens=2,*" %%A IN ('REG QUERY %JAVA_CURRENT% /v %J_HOME% 2^>nul') DO (
     67    set JAVA_PATH=%%B
     70if not defined JAVA (set JAVA="%JAVA_PATH%\bin\java.exe")
     74:: The binary in %JAVA% should exist, assuming it was set by us. Perhaps it
     75:: won't if the user specified it manually. Let's check to be sure.
     77if not exist %JAVA% (
     78    echo. Could not find %JAVA%. Please ensure that the variable JAVA
     79    echo. refers to a path that exists.
     80    goto end
     82%JAVA% -cp "%_I2PHOME%\lib\i2p.jar" net.i2p.util.EepGet %1 %2 %3 %4 %5
Note: See TracChangeset for help on using the changeset viewer.