Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
One of my windows service uses the java.exe to run. The path where java lies in my C drive is stored in a registry entry. Java keeps updating its revision when updates happens and it keeps deleting the old folder and creates a new one. This new path needs to be updated in my registry entry other wise my windows service stops.
One solution I can think is use the registry entry that points to java path as a value in my registry entry, so that my reg entry does not have a hard coded java path.

Basically I want to use the value at this registry entry(which is C:\Program Files (x86)\Java\jre1.8.0_131\bin\javaws.exe)

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\windows\CurrentVersion\App Paths\javaws.exe

in other registry entry : HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EngineWithJenkins\Parameters@Path

What I have tried:

I have used these two methods but they failed:

$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\windows\CurrentVersion\App Paths\javaws.exe@Path)

and directly the path

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\windows\CurrentVersion\App Paths\javaws.exe\Path
Posted
Updated 7-Jul-17 1:03am
Comments
RickZeeland 7-Jul-17 6:01am    
And what programming language are you using ? please tag your question.

1 solution

You must use the registry entries of the Java installaion, not these values. Tip: You can also use EnumRegistry

Another solution is to find the javaws.exe in the program files folder of the disk with FindFirstFile. See the example code.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900