How to create shortcut icon for java program

前端 未结 11 2534
野性不改
野性不改 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:11

    100% Working native windows shortcut for jar execution:

    First create regular windows shortcut (right click on desktop, new -> shortcut)
    In text field "Type the location of the item" write:
    "C:\path\to\javaw.exe" -jar "C:\path\to\jar\myExecutableJar.jar"

    enter image description here

    Click next, type shortcut name ant press Finish.

    That's all! :)

    Then You can set custom icon:

    Right click on shortcut -> Properties -> Change Icon...

    enter image description here

    0 讨论(0)
  • 2020-12-29 11:12

    You should be able to create shortcut as normal.

    After all, installing Java on Windows should by default allow you to run .jar files directly; there should be an association of that extension to java.exe. Alternatively, you can create a batch file to run the jar and then create the shortcut for that file.

    0 讨论(0)
  • 2020-12-29 11:12

    If Java is properly installed, the JAR extension is assigned to java. That means on commandline you can type

    C:> myprogram.jar 
    

    And if your jar is properly build that runs the program.

    You can copy/paste-link your JAR file to desktop.

    0 讨论(0)
  • 2020-12-29 11:19

    This is a short tutorial for creating shortcuts to existing programs: http://support.microsoft.com/kb/140443

    0 讨论(0)
  • 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!

    0 讨论(0)
提交回复
热议问题