2

Struggling to create a desktop shortcut for a jar file.

Found a solution which created a .url file aka

   [InternetShortcut]
    URL=D:/test.jar

which worked pretty well. But then the stakes went higher and now i need to run in from a certain JRE. Basically, what i'w tried, was to fix the URL to %javapath%/java.exe -jre d:/test.jar, but Win7 started to treat it as a web-url, adding a "http://" at the start of the url when looking through file properties.

Is there a way to make this work? Or maybe a freeware library that can create urls in a more graceful way?


Upd: Finally struck on an answer(and yes, i found in on stockoverflow) - Creating a shortcut file from Java

If someone gets here, looking for the answer:

ShellLink sl = ShellLink.createLink("C:/Program Files (x86)/Java/jre1.8.0_121/bin/javaw.exe");
sl.setCMDArgs("-jar D:/Test1.jar");
Community
  • 1
  • 1
Draaksward
  • 759
  • 7
  • 32
  • Possible duplicate of [Run .jar through Windows shortcut passing arguments](http://stackoverflow.com/questions/29266233/run-jar-through-windows-shortcut-passing-arguments) – Michael May 11 '17 at 08:38
  • On that topic, the user wants simply to run a jar file with arguments through a windows .lnk file. The thing is that i want to create a link using pure Java. – Draaksward May 11 '17 at 08:44
  • I am using a BAT file and create a shortcut to the BAT file. You can put your arguments in the shortcut command line, BAT file or a resource file such as `.properties` or `xml` or another. – Binyamin Regev May 11 '17 at 08:45
  • Yea, you can create a bat file for that and create a link for it, but i want to directly create a link for the jar file. The other option for this is to create the link manually, store it in the package and then copy it to the desktop, but that seems a bit wrong. – Draaksward May 11 '17 at 08:48

0 Answers0