Win a copy of Rust Web Development this week in the Other Languages forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

How to create shortcut for a file using JAVA

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
dear all,
i want to create an installation wizard for the appication that i have developed.my basic idea is to create a batch file to run my application and put in in a paricular location and a shortcut for the batch file and place it in desk top ,but i dont have an idea to create a shortcut for the batch file in run time using java code.could any body help me out in solving this problem.
thanks in advance
Shiva
 
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any particular operating system in mind?
 
Author
Posts: 6055
8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
On windows, I simply make a .bat file which runs the command line to run my java app, i.e.
java -classpath "..." -D<somekey/value> MyProgram
I have my installer include this file during installation.
It gets trickier if the JRE, classpath, and/or program can have a variable location. You need to use some combination of calls to the system, DOS commands (or cygwin commands if possible), and possible even MFC to figure out what to do. I would not try to do a shorcut in Java.
--Mark
 
Shiva Kumar
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks for reply
currently we need to create shortcut for Windows OS for the batch file that we create could you help me out.
Shiva
 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For this, you may want to open up a sample shortcut file in something like Notepad. It may be in plaintext and not some binary format, so you may be able to get away with creating the file using just the java.io.FileWriter.
Let me know if it works.
 
Shiva Kumar
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

when i tried to open shortcut file in notepad or other utilities it only internally opens the original file for which shortcut is created.so i tried opening in dos prompt using 'type' command it showed the following:
L ☺�☻ └ F� P⌂;B╣╗☺ D♥☻n■└☺ ╡
how could we solve this.help me out
 
jasonkosowan
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oops, looks like shortcuts are binary encoded. Oh well, worth a try! Looks like you might have to invoke some JNI to get this to work if there is a command to create a shortcut. Would probably be your best bet now.

Originally posted by Shiva Kumar:

when i tried to open shortcut file in notepad or other utilities it only internally opens the original file for which shortcut is created.so i tried opening in dos prompt using 'type' command it showed the following:
L ☺�☻ └ F� P⌂;B╣╗☺ D♥☻n■└☺ ╡
how could we solve this.help me out


 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic