1

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).

Background

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.

3
  • Some more info for clarification. 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. Commented May 18, 2012 at 17:21
  • "The installer we are using is Java based, which is why I'm looking for the solution in Java." That sounds like JWS. If not then perhaps you can be more specific, instead of forcing us to play this game of '20 questions'. Commented May 18, 2012 at 18:15
  • 1
    Andrew, I liked your answer, but it was not applicable for my particular application. I believe that it might be useful for others though, and you'll probably get votes up for your response, when it is applicable for people who read the post later. Commented May 18, 2012 at 18:26

3 Answers 3

4

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).

Desktop shortcuts

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.

Sign up to request clarification or add additional context in comments.

1 Comment

I can't speak for VenomFangs but in our case users don't want automatic upgrades, and with the increasing number of java exploits that are almost all related to java webstart or applets it doesn't make sense to expose ourselves to additional vulnerability if we don't have to. Our organization has required us to minimize the use of JWS and applets as much as possible, so having a more direct method to create shortcuts in our installer like this question asked would be very helpful.
2

"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.

2 Comments

Thanks for the comment and link. I'll look through it... I might end up just writing something in C#.
I'll be using something like the following to make the shortcuts with icons for me. eggheadcafe.com/community/csharp/2/10084566/… I'll pass the specifics via command line, then I should be able to tie it in nicely with my install process.
1

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.

enter image description here

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.