Find java in registry

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

Java path in Windows registry #7

Java path in Windows registry #7

Comments

Can you make the windows installer add this registry stuff with the correct OpenJDK installation-path?

===BEGIN===
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment\1.7]
«JavaHome»=»C:\Programme\Java\OpenJDK7_u6\jre»

It’s needed by some (maybe all) Window Software to find Java. Until now, I’ve successfully tested it with «openjdk-1.7.0-u6-unofficial-b24-windows-i586.zip» and this software:

The text was updated successfully, but these errors were encountered:

I wanted to add OpenJDK in http://compilibre.sourceforge.net/index_fr-FR.html , with LibreOffice, FAR and many more softwares that require JAVA. But it is too hard for a normal user to add a registry key or to set a variable. So, I will wait a new version of OpenJDK with PATH and JAVA_HOME or/and the registry key set by the installer.

I’ll look at it. Now I’m awaiting for new source releases: openjdk7 update should be released in a month and openjdk6 update may also be released soon.

Читайте также:  Setting css with javascript

@kolAflash , @petrouchka
New installers in 7u40_2.4.1 support environment variables and windows registry. I’ve tested these features on win7 x64, but they may not work across all windows versions. Please reopen this issue (or file a new one) in case of errors.

Any ETA on when this will be fixed? Because i have issues with the installer too

Yes i tried adding manuel reg keys not working for me, can’t say i’m pro at adding regkeys though. i assumed a string would be sufficient

All current windows installers support adding registry keys. You most
probably will need to run the installer with right click+»As
Administrator» for registry access to work, though.

On 10/24/2014 06:03 PM, Rikitik wrote:

Yes i tried adding manuel reg keys not working for me, can’t say i’m pro at adding regkeys though. i assumed a string would be sufficient

Reply to this email directly or view it on GitHub:
#7 (comment)

Hello
As I noticed Launch4J works with the key CurrentVersion which is located in windows registry :
HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment

for example if CurrentVersion=1.8.0_05 the app try to look at a folder key 1.8.0_05 underneath of Java Runtime Environment so the path to look up is:
HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment\1.8.0_05

Then from there you should have the JDK OR JRE path with JavaHome Key EX:
[JavaHome]=[C:\Program Files\java\jdk8-u5]

Here is exported registry myfile.reg content. TAKE NOTE YOU SHOULD CHANGE THE VALUES TO YOUR VERSION AND YOUR PATH :

Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft] [HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment] "CurrentVersion"="1.8.0_05" [HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment\1.8.0_05] "JavaHome"="C:\\Program Files\\java\\jdk8-u5" [HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Prefs] 

Источник

Finding Java CurrentVersion in the Windows 7 registry

I support an old Java client application that runs fine on Windows XP but not Windows 7 32 bit. The problem is in the BAT file used to launch the application. The BAT file contains code that queries the registry for the CurrentVersion of Java and then uses that value to determine the path of that version of Java on the user’s computer. This is needed in order to include rt.jar on the CLASSPATH when the Java client application is launched. The following code works fine on Windows XP, but on Windows 7 it returns:

«HKLMSOFTWAREJavaSoftJava Runtime Environment»CurrentVersion not found.

:find_java setlocal ENABLEEXTENSIONS set KEY_NAME="HKLMSOFTWAREJavaSoftJava Runtime Environment" set VALUE_NAME=CurrentVersion :: :: get the current version :: FOR /F "usebackq skip=4 tokens=3" %%A IN (`REG QUERY "HKLMSOFTWAREJavaSoftJava Runtime Environment" /v CurrentVersion 2^>nul`) DO ( set ValueValue=%%A ) if defined ValueValue ( @echo the current Java runtime is %ValueValue% ) else ( @echo %KEY_NAME%%VALUE_NAME% not found. goto return ) set JAVA_CURRENT="HKLMSOFTWAREJavaSoftJava Runtime Environment%ValueValue%" set JAVA_HOME=JavaHome :: :: get the javahome :: FOR /F "usebackq skip=4 tokens=3,4" %%A IN (`REG QUERY %JAVA_CURRENT% /v %JAVA_HOME% 2^>nul`) DO ( set JAVA_PATH=%%A %%B ) set JAVA_PATH=%JAVA_PATH:Program Files=Progra~1% echo using %JAVA_PATH% set JAVA_HOME=%JAVA_PATH% echo. :return goto start 

I’m not savvy when it comes to complex DOS command programming. Any clues on how I can update this code so that it will work under Windows 7 (32 bit)?

Answers

@echo off setlocal enableextensions disabledelayedexpansion :: possible locations under HKLMSOFTWARE of JavaSoft registry data set "javaNativeVersion=" set "java32ON64=Wow6432Node" :: for variables :: %%k = HKLMSOFTWARE subkeys where to search for JavaSoft key :: %%j = full path of "Java Runtime Environment" key under %%k :: %%v = current java version :: %%e = path to java set "javaDir=" set "javaVersion=" for %%k in ( "%javaNativeVersion%" "%java32ON64%") do if not defined javaDir ( for %%j in ( "HKLMSOFTWARE%%~kJavaSoftJava Runtime Environment" ) do for /f "tokens=3" %%v in ( 'reg query "%%~j" /v "CurrentVersion" 2^>nul ^| find /i "CurrentVersion"' ) do for /f "tokens=2,*" %%d in ( 'reg query "%%~j%%v" /v "JavaHome" 2^>nul ^| find /i "JavaHome"' ) do ( set "javaDir=%%~e" & set "javaVersion=%%v" ) ) if not defined javaDir ( echo Java not found ) else ( echo JAVA_HOME="%javaDir%" echo JAVA_VERSION="%javaVersion%" ) endlocal 

Источник

[Windows] Search for Java installation in registry using BATCH script

Check for the Java installation scanning through registry. This batch file searches for Java 6 Update 16 (32 bit) or above. If any version of Java that is older than this is found, it will error out.

@ECHO OFF setlocal ENABLEEXTENSIONS IF %PROCESSOR_ARCHITECTURE%==AMD64 GOTO CHECK_JAVA_64 IF %PROCESSOR_ARCHITECTURE%==x86 GOTO CHECK_JAVA_32 @ECHO Detecting Java version installed. :CHECK_JAVA_64 @ECHO Detecting if it is 64 bit machine set KEY_NAME="HKEY_LOCAL_MACHINE\Software\Wow6432Node\JavaSoft\Java Runtime Environment" set VALUE_NAME=CurrentVersion set VALUE_FAMILYNAME=Java6FamilyVersion FOR /F "usebackq skip=2 tokens=1-3" %%A IN (`REG QUERY %KEY_NAME% /v %VALUE_NAME% 2^>nul`) DO ( set ValueName=%%A set ValueType=%%B set ValueValue=%%C ) @ECHO CurrentVersion %ValueValue% IF "%ValueValue%" == "1.6" ( FOR /F "usebackq skip=2 tokens=1-3" %%A IN (`REG QUERY %KEY_NAME% /v %VALUE_FAMILYNAME% 2^>nul`) DO ( set ValueFamilyName=%%A set ValueFamilyType=%%B set ValueFamilyValue=%%C ) ) IF "%ValueValue%" == "1.6" ( IF "%ValueFamilyValue%" LSS "1.6.0_16" GOTO JAVA_NOT_INSTALLED ) SET KEY_NAME="%KEY_NAME:~1,-1%\%ValueValue%" SET VALUE_NAME=JavaHome if defined ValueName ( FOR /F "usebackq skip=2 tokens=1,2*" %%A IN (`REG QUERY %KEY_NAME% /v %VALUE_NAME% 2^>nul`) DO ( set ValueName2=%%A set ValueType2=%%B set JRE_PATH2=%%C if defined ValueName2 ( set ValueName = %ValueName2% set ValueType = %ValueType2% set ValueValue = %JRE_PATH2% ) ) ) IF NOT "%JRE_PATH2%" == "" GOTO JAVA_INSTALLED IF "%JRE_PATH2%" == "" GOTO JAVA_NOT_INSTALLED :CHECK_JAVA_32 @ECHO Detecting if it is 32 bit machine set KEY_NAME="HKEY_LOCAL_MACHINE\Software\JavaSoft\Java Runtime Environment" set VALUE_NAME=CurrentVersion set VALUE_FAMILYNAME=Java6FamilyVersion FOR /F "usebackq skip=2 tokens=1-3" %%A IN (`REG QUERY %KEY_NAME% /v %VALUE_NAME% 2^>nul`) DO ( set ValueName=%%A set ValueType=%%B set ValueValue=%%C ) @ECHO CurrentVersion %ValueValue% IF "%ValueValue%" == "" GOTO CHECK_JAVA_32 IF "%ValueValue%" == "1.6" ( FOR /F "usebackq skip=2 tokens=1-3" %%A IN (`REG QUERY %KEY_NAME% /v %VALUE_FAMILYNAME% 2^>nul`) DO ( set ValueFamilyName=%%A set ValueFamilyType=%%B set ValueFamilyValue=%%C ) ) IF "%ValueValue%" == "1.6" ( IF "%ValueFamilyValue%" LSS "1.6.0_16" GOTO JAVA_NOT_INSTALLED ) SET KEY_NAME="%KEY_NAME:~1,-1%\%ValueValue%" SET VALUE_NAME=JavaHome if defined ValueName ( FOR /F "usebackq skip=2 tokens=1,2*" %%A IN (`REG QUERY %KEY_NAME% /v %VALUE_NAME% 2^>nul`) DO ( set ValueName2=%%A set ValueType2=%%B set JRE_PATH2=%%C if defined ValueName2 ( set ValueName = %ValueName2% set ValueType = %ValueType2% set ValueValue = %JRE_PATH2% ) ) ) IF "%JRE_PATH2%" == "" GOTO JAVA_NOT_INSTALLED :JAVA_INSTALLED REM Do whatever you want to do when Java is installed GOTO END :JAVA_NOT_INSTALLED REM Do whatever you want to do when Java is NOT installed PAUSE GOTO END :END REM End of Batch File

Источник

Java – Finding Java CurrentVersion in the Windows 7 registry

I support an old Java client application that runs fine on Windows XP but not Windows 7 32 bit. The problem is in the BAT file used to launch the application. The BAT file contains code that queries the registry for the CurrentVersion of Java and then uses that value to determine the path of that version of Java on the user’s computer. This is needed in order to include rt.jar on the CLASSPATH when the Java client application is launched. The following code works fine on Windows XP, but on Windows 7 it returns:

«HKLM\SOFTWARE\JavaSoft\Java Runtime Environment»\CurrentVersion not found.

:find_java setlocal ENABLEEXTENSIONS set KEY_NAME="HKLM\SOFTWARE\JavaSoft\Java Runtime Environment" set VALUE_NAME=CurrentVersion :: :: get the current version :: FOR /F "usebackq skip=4 tokens=3" %%A IN (`REG QUERY "HKLM\SOFTWARE\JavaSoft\Java Runtime Environment" /v CurrentVersion 2^>nul`) DO ( set ValueValue=%%A ) if defined ValueValue ( @echo the current Java runtime is %ValueValue% ) else ( @echo %KEY_NAME%\%VALUE_NAME% not found. goto return ) set JAVA_CURRENT="HKLM\SOFTWARE\JavaSoft\Java Runtime Environment\%ValueValue%" set JAVA_HOME=JavaHome :: :: get the javahome :: FOR /F "usebackq skip=4 tokens=3,4" %%A IN (`REG QUERY %JAVA_CURRENT% /v %JAVA_HOME% 2^>nul`) DO ( set JAVA_PATH=%%A %%B ) set JAVA_PATH=%JAVA_PATH:Program Files=Progra~1% echo using %JAVA_PATH% set JAVA_HOME=%JAVA_PATH% echo. :return goto start 

I’m not savvy when it comes to complex DOS command programming. Any clues on how I can update this code so that it will work under Windows 7 (32 bit)?

Best Solution

@echo off setlocal enableextensions disabledelayedexpansion :: possible locations under HKLM\SOFTWARE of JavaSoft registry data set "javaNativeVersion=" set "java32ON64=Wow6432Node\" :: for variables :: %%k = HKLM\SOFTWARE subkeys where to search for JavaSoft key :: %%j = full path of "Java Runtime Environment" key under %%k :: %%v = current java version :: %%e = path to java set "javaDir=" set "javaVersion=" for %%k in ( "%javaNativeVersion%" "%java32ON64%") do if not defined javaDir ( for %%j in ( "HKLM\SOFTWARE\%%~kJavaSoft\Java Runtime Environment" ) do for /f "tokens=3" %%v in ( 'reg query "%%~j" /v "CurrentVersion" 2^>nul ^| find /i "CurrentVersion"' ) do for /f "tokens=2,*" %%d in ( 'reg query "%%~j\%%v" /v "JavaHome" 2^>nul ^| find /i "JavaHome"' ) do ( set "javaDir=%%~e" & set "javaVersion=%%v" ) ) if not defined javaDir ( echo Java not found ) else ( echo JAVA_HOME="%javaDir%" echo JAVA_VERSION="%javaVersion%" ) endlocal 

Источник

Оцените статью