Create Desktop shortcut

前端 未结 3 1739
庸人自扰
庸人自扰 2020-12-21 01:26

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 ? O

3条回答
  •  有刺的猬
    2020-12-21 02:00

    This is a fairly old topic, nevertheless I came across Austin`s brilliant answer and encountered some problems using jshortcut from within NetBeans, but I fear this might also affect Ecclipse.

    1. Adding jshortcut.dll to java.library.path from wihtin NetBeans using properties->Run->VM options did not work.
    2. Adding this dll by source code like "System.setProperty("java.library.path", yourDllPath)" does not work either.
    3. Instead put jshortcut.dll to that particular folder where you store your jars for this project. JShellLink looks at this folder on its own, so you dont need to add the DLL`s path to any path, which could cause trouble when running on some closed-down machines.
    4. Most Important: When downloading your jshortcut.dll- Version, use AMD for all actual Intel machines. Rename the dll to shortcut.dll after downloading. JShellLink only looks for shortcut.dll, it ignores all other names.

    Excert form jShellLink: /** Provide access to shortcuts (shell links) from Java. * * The native library (jshortcut.dll) is loaded when JShellLink is first * loaded. * By default, JShellLink first looks for the native library in the PATH, * using System.loadLibrary. * If the native library is not found in the PATH, * JShellLink then looks through each directory in the CLASSPATH * (as determined by the value of the system property java.class.path). * If an entry in the CLASSPATH is a jar file, * then JShellLink looks for the native library * in the directory containing that jar file. * The application can override this behavior and force JShellLink to look * for the native library in a specific directory by setting the system * property JSHORTCUT_HOME to point to that directory. * This property must be set before the JShellLink class is loaded. * This makes it possible to use this library from a self-extracting jar file. */

提交回复
热议问题