File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes Creating desktop shortcut from Java program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Creating desktop shortcut from Java program" Watch "Creating desktop shortcut from Java program" New topic

Creating desktop shortcut from Java program

Barry Andrews
Ranch Hand

Joined: Sep 05, 2000
Posts: 523

Hi All,
I am really hoping someone knows how to do this, because I have no clue. From my Java app, I am creating a .bat file and putting it on the desktop. This batch file is for starting another Java app. What I would like to do is actually make this file a shortcut (from the Java app, not by right clicking it) so that it will no longer have to have the .bat extension, but it can be anything. Also, it would be nice if I can associate an image with this shortcut (also doing this from the Java app) Does anyone know how to do this or know where I could find this information? Thanks a lot!!!

P.S. I am working on NT machine.
Robert , doodle

Joined: May 25, 2001
Posts: 8
create a shortcut
search for your bat file
rename the shortcut....
click on properties to set your picture

it is not a java question i think.....
Barry Andrews
Ranch Hand

Joined: Sep 05, 2000
Posts: 523

You totally ignored what I had in parenthesis. I know how to do that. There should be a way to do this from within a Java app. How do you think Oracle, Microsoft, IBM, Napster, or anybody else place a shortcut on your desktop? It is done within their code. There has to be a way from my Java code. Does anyone have any suggestions? Many thanks!!!

Angela Lamb
Ranch Hand

Joined: Feb 22, 2001
Posts: 156
You would need to use native code for that. It won't work from pure Java code, since shortcuts aren't like regular files.
Aj Manch
Ranch Hand

Joined: May 07, 2001
Posts: 50
I am not sure how to make a shortcut file in Java. I feel that this has a native code and JNI solution.
But if you know that the executable file is in the path, create a batch file with the just the name of the file and move it to desktop directory. In this case the image that you are going to see will be the one for notepad's.
I agree. Here's the link:
subject: Creating desktop shortcut from Java program
It's not a secret anymore!