Reputation: 20381
I'm looking for a way to create shortcuts in java for WinXP, Vista, and Win7. In addition to the shortcut itself, I need to be able to specify the icon of the shortcut.
The solution can use command line commands, however I cannot use a solution that is GPL.
If WinXP creates shortcuts differently than Vista/7, than I'm okay with adding conditional logic (I'll just need to know how to do it for both cases).
The shortcut creation will happen during the install process. The installer we are using is Java based, which is why I'm looking for the solution in Java. So it is important to note that the shortcut can vary, based on the user's selected install directory. If there is not a clean way to do this, then I will have to go with the recommend suggestion of creating a VBScript or C# program to do the work for me, then call that from my java code. I would prefer a simpler solution though.
Upvotes: 1
Views: 3444
Reputation: 197
I write a swt win32 extension for the win32 api call.
You can use it to make a windows shortcut.
You can download the library from http://feeling.sourceforge.net, it's open source.
But if you want to use it, you should depend on the eclipse swt library.
Upvotes: 1
Reputation: 168845
Deploy the app. using Java Web Start.
JWS provides many appealing features including, but not limited to, splash screens, desktop integration, file associations, automatic update (including lazy downloads and programmatic control of updates), partitioning of natives & other resource downloads by platform, architecture or Java version, configuration of run-time environment (minimum J2SE version, run-time options, RAM etc.), easy management of common resources using extensions..
The desktop shortcut is typically specified in the JNLP file used to provide the values needed to launch the app. It can include an icon.
Here is a small section of my desktop (Windows 7).
The two shortcuts on the RHS are JWS apps. The bottom one (Star Zoom Animation) defined an icon, while the other uses the default 'coffee cup' icon.
Upvotes: 4
Reputation: 121809
"Windows shortcuts" are a combination of COM/ActiveX Monikers and Win32 APIs.
Neither of which are exposed directly by Java to the JVM environment.
SUGGESTION: Just write a little VBscript that your Java program invokes (getRuntime()/Process.exec()).
Or make use of a package that already does what you're looking for.
Upvotes: 2