JShortcut is a Java package and JNI library to allow Java programs to create and read shortcuts and menu items (ShellLinks) under Windows.
Go to the JShortcut home page to download the latest version of JShortcut.
The javadoc-generated API Reference provides detailed documentation on the packages and classes used in JShortcut.
JShortcut is delivered in a self-extracting JAR file. You must have Java running on your system in order to extract it.
To install JShortcut from the installation JAR file (.jar extension), double-click on the JAR file, or run the command
This will open a dialog allowing you to specify a destination directory, and it will create a directory called jshortcut-N_N in the specified directory, where N_N is replaced by the JShortcut version number.
java -jar jshortcut-N_N.jar
To use JShortcut, you only need two files from the JShortcut distribution: jshortcut.jar and jshortcut.dll (but remember that the GPL requires you to make the source available when you redistribute JShortcut with your program). You don't need to build anything in the JShortcut kit in order to use it.
Copy the files jshortcut.jar and jshortcut.dll into one of the directories in your CLASSPATH. If your program runs from a jar file, you can put both of those files into the same directory as your main jar file, and add the following line to the manifest in your jar file:
Use code such as the following to create a shortcut on the desktop:
import net.jimmc.shortcut.JShellLink; ... String jarFileName = JShellLink("program_files")+"\\myprogram\\myprogram.jar"; //This might be a good place to put your program JShellLink link = new JShellLink(); link.setFolder(JShellLink.getDirectory("desktop")); link.setName("My Program"); link.setPath(jarFileName); link.save();
You may want to use the JShortcut capabilities from a self-extracting jar file when installing your program. This allows you to get such useful values as the location of the Program Files directory, which you might want as a default when asking the user where he wants to install your program.
To use JShortcut during the self-extraction, you will need to take the following steps:
If you make changes to the source files in JShortcut, you will need to rebuild it. For instructions on how to build JShortcut, see the file README.build.
Bug Reports and Feedback
If you have a comment about JShortcut, or would like to report a bug, please send email to jimmc -at- nwlink.com
JShortcut was written by Jim McBeath <jimmc -at- nwlink.com>, http://alumni.caltech.edu/~jimmc