• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Creating Windows desktop shortcut to jar

 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I am writing a generic installer for a bunch of small apps I have made in Java. They are all executable jar files and the installer writes them and any other required files to a default directory that varies depending on operating system. The only thing I am having trouble with is figuring out how to create a desktop shortcut to these apps. I need to create the shortcut and set its icon to a file I install with my software. Does anyone know how to go about doing this? For now I am focusing on windows only (I know it is different for every os .
 
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I did some googling (hey, even you can google for windows command line create shortcut) and there are some Windows Scripting Host scripts available to do this.
 
Colin McTaggart
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I did spend a lot of time googling this problem before I posted actually. What I was searching for is a native java way to do this, in part this was so that I could get some practice using output streams as this is a weakness of mine. This would also mean I could use the same basic code for linux and mac but with a different kind of file being written. I know windows shortcuts are not going to be natively supported in a cross platform language but if you know how a file is constructed you can create it. I guess I'll just use native code if no-one knows a pure java way.

Thanks for your time guys.
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Colin McTaggart wrote:but if you know how a file is constructed you can create it.



That's exactly right. So you need to find the specifications for a Windows shortcut. I would expect to find that on Microsoft's developer site, although I have heard that Microsoft hasn't actually made those specs public. But that could be just a rumour, or out of date, or just wrong.

Or you could reverse-engineer a shortcut file which looks like one which you would like to generate. Don't know how easy that would be.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic