Hi I have created executable jar of my java program i want to create shortcut icon for that jar. Means may be my jar is in any other memory location of hard drive(eg- D or E
100% Working native windows shortcut for jar execution:
First create regular windows shortcut (right click on desktop, new -> shortcut)
In text field "Type the location of the item" write:
"C:\path\to\javaw.exe" -jar "C:\path\to\jar\myExecutableJar.jar"
Click next, type shortcut name ant press Finish.
That's all! :)
Then You can set custom icon:
Right click on shortcut -> Properties -> Change Icon...
You should be able to create shortcut as normal.
After all, installing Java on Windows should by default allow you to run .jar files directly; there should be an association of that extension to java.exe. Alternatively, you can create a batch file to run the jar and then create the shortcut for that file.
If Java is properly installed, the JAR extension is assigned to java. That means on commandline you can type
C:> myprogram.jar
And if your jar is properly build that runs the program.
You can copy/paste-link your JAR file to desktop.
This is a short tutorial for creating shortcuts to existing programs: http://support.microsoft.com/kb/140443
I'm not entirely sure about this answer, but I've recently found this:
try {
Files.createLink(FileSystems.getDefault().getPath("C:/Documents and Settings/MyUser/Desktop", "MyLink.lnk")
, FileSystems.getDefault().getPath("C:/Documents and Settings/MyUser/Desktop", "MyExistingFile.pdf"));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
This example create a link (shortcut) in the desktop to another file in the desktop.
it in deed creates a shortcut recognized by the OS, but I have not been able to make it work in Windows systems (the shortcut is been created and it is recognized by Windows but it does not work), but I'm working on it, so as soon as I get the answer I'll post it here, in the meantime, you may try to help me, lets see who is the first to make it work :D!
Greetings!