创建桌面快捷方式

gee*_*guy 4 java desktop-application

我正在研究一个java应用程序.

我想创建应用程序的Exe文件的桌面快捷方式.

可以从我的应用程序本身做到吗?或者用户必须通过右键单击手动执行此操作?

Hus*_*ri' 9

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();
    }
}
Run Code Online (Sandbox Code Playgroud)

你可以从这里拿到罐子