Advertisement
Guest User

Untitled

a guest
Dec 12th, 2018
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. import net.jimmc.jshortcut.JShellLink;
  2.  
  3. String PRJT_PATH="";
  4. private void getdir() throws IOException{
  5. File f=new File(".");
  6. File[] f1=f.listFiles();
  7. PRJT_PATH=f.getCanonicalPath();
  8. } //you can call this function at windowOpened event,this will get path of current directory where your project located.
  9.  
  10. JShellLink link;
  11. String filePath;
  12.  
  13. public void createDesktopShortcut() { //after that call createDesktopShortcut() function to create shortcut to desktop.
  14. try {
  15. link = new JShellLink();
  16. filePath = JShellLink.getDirectory("") + PRJT_PTH +"\\JMM.jar";
  17. } catch (Exception e) {
  18.  
  19. }
  20.  
  21. try {
  22. link.setFolder(JShellLink.getDirectory("desktop"));
  23. link.setName("JMM"); //Choose a name for your shortcut.In my case its JMM.
  24. link.setPath(filePath); //link for our executable jar file
  25. link.setIconLocation(PRJT_PATH1+ "\\jmm.ico"); //set icon image(before that choose your on manual icon file inside our project folder.[jmm.ico in my case])
  26. link.save();
  27. } catch (Exception ex) {
  28. ex.getmessage();
  29. }
  30.  
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement