Execute a jar from a custom URL protocol

590 views Asked by At

I successfully created a custom URL protocol in Windows following this instructions that targets a simple jar that I created, I can run this jar manually by executing this command (java is in the PATH):

java -jar test.jar

But when I open an URL that uses my custom protocol, it doesn't execute the jar, the protocol is supposed to execute the same command, this is how it looks in the Registry Editor:

"C:\Program Files\Java\jdk1.8.0_152\bin\java.exe -jar C:\testFolder\test.jar" "%1"

If I replace the jar with an .exe file it works fine, for example notepad.exe or the calculator, so the problem is executing the jar.

1

There are 1 answers

0
Wormy On
"C:\Program Files\Java\jre1.8.0_202\bin\java.exe" "-jar" "C:\Users\user\Desktop\DisplayStartArgumentsInFrame.jar" "%1"

Is the required command in the registry entry. I was also trying around with url protocols and had the same problem. I don't know why, but it works.

Edit: use javaw.exe instead of java.exe to suppress the terminal.