Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Creating desktop shortcut from Java program

 
Barry Andrews
Ranch Hand
Posts: 523
C++ Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!!!

Barry
P.S. I am working on NT machine.
 
Robert , doodle
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 523
C++ Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!!!

Barry
 
Angela Lamb
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic