Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I am working on a java application.

I want to create desktop shortcut of my application's Exe file.

Is is possible to do it from my application itself ? Or user has to do it manually by right clicking ?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
183 views
Welcome To Ask or Share your Answers For Others

1 Answer

package farzi;

import net.jimmc.jshortcut.JShellLink;

public class Sc {
    JShellLink link;
    String filePath;

    public Sc() {
        try {
            link = new JShellLink();
            filePath = JShellLink.getDirectory("")
                + "C:\Program Files\Internet Explorer\iexplore.exe";

        } catch (Exception e) {

        }

    }

    public void createDesktopShortcut() {

        try {
            link.setFolder(JShellLink.getDirectory("desktop"));
            link.setName("ie");
            link.setPath(filePath);
            link.save();
        } catch (Exception ex) {
            ex.printStackTrace();
        }

    }

    public static void main(String a[]) {
        Sc sc = new Sc();
        sc.createDesktopShortcut();
    }
}

you can get the jar from here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...