dushkin dushkin - 1 month ago 10
Java Question

How to launch a jar file on windows startup from the registry?

I am trying to launch a jar file on Windows Server 2008 R2 startup.

I tried to add a key\value to

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run


I tried as a value several alternatives:

java -jar c:\jcm\jcm.jar
"java -jar c:\jcm\jcm.jar"
c:\program files(x86)\java\jre1.8.31\bin\java.exe -jar c:\jcm\jcm.jar
"c:\program files(x86)\java\jre1.8.31\bin\java.exe -jar c:\jcm\jcm.jar"
"c:\program files(x86)\java\jre1.8.31\bin\java.exe" -jar c:\jcm\jcm.jar


But none of them launched the program.

Can you advise please?




EDIT: Fixed exe to jar of course.. Thanks

Thank you.

Answer

You probably have a problem in the command line. I think it should be something like that last row that you have used but with jar and not exe.

"c:\program files(x86)\java\jre1.8.31\bin\java.exe" -jar c:\jcm\jcm.jar

You just need to test it in command line first and if it works it will work in the registry. You can also make a .bat file to start the java program and copy that to windows Startup Folder instead of using the registry.

The startup folder you can find here: http://windows.microsoft.com/en-us/windows/run-program-automatically-windows-starts#1TC=windows-7