从Java创建快捷方式链接(.lnk)

我正在用Java编写安装程序(启动程序),并且需要能够在此过程中在用户桌面上创建快捷方式。

我对任何想法感兴趣是最好的方法。 我考虑的一个选项是在Windows上使用VB脚本并使用本机’shortcut.exe’为我做,但是第三方文件实用程序将是首选。

/** * Create an Internet shortcut * @param name name of the shortcut * @param where location of the shortcut * @param target URL * @param icon URL (ex. http://www.server.com/favicon.ico) * @throws IOException */ public static void createInternetShortcut (String name, String where, String target, String icon) throws IOException { FileWriter fw = new FileWriter(where); fw.write("[InternetShortcut]\n"); fw.write("URL=" + target + "\n"); if (!icon.equals("")) { fw.write("IconFile=" + icon + "\n"); } fw.flush(); fw.close(); } 

完整示例: 创建Internet快捷方式(Windows)

看到这个类似的问题。 而且这个 。

快速谷歌搜索后,我找到了这个java库: http : //alumnus.caltech.edu/~jimmc/jshortcut/