How to create shortcut icon for java program

前端 未结 11 2618
野性不改
野性不改 2020-12-29 10:57

Hi I have created executable jar of my java program i want to create shortcut icon for that jar. Means may be my jar is in any other memory location of hard drive(eg- D or E

11条回答
  •  鱼传尺愫
    2020-12-29 11:21

    I'm not entirely sure about this answer, but I've recently found this:

        try {
            Files.createLink(FileSystems.getDefault().getPath("C:/Documents and Settings/MyUser/Desktop", "MyLink.lnk")
                    , FileSystems.getDefault().getPath("C:/Documents and Settings/MyUser/Desktop", "MyExistingFile.pdf"));
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    

    This example create a link (shortcut) in the desktop to another file in the desktop.

    it in deed creates a shortcut recognized by the OS, but I have not been able to make it work in Windows systems (the shortcut is been created and it is recognized by Windows but it does not work), but I'm working on it, so as soon as I get the answer I'll post it here, in the meantime, you may try to help me, lets see who is the first to make it work :D!

    Greetings!

提交回复
热议问题