How to run Java programs by clicking on their icon on Windows?

后端 未结 12 2676
太阳男子
太阳男子 2020-12-01 22:52

I have written a Java program that uses Java swing library. Now I would like to execute this program by double clicking on the executable file on Windows just like any other

12条回答
  •  我在风中等你
    2020-12-01 23:17

    Seems you want to deploy and run the standalone application of swings. Being a java developer you should understand the power of jar files. Those are executable in themselves {so no need to create .exe files :)} .

    The below code will help you to create a jar file.

    Creating a jar File in Command Prompt

    Start Command Prompt.
    Navigate to the folder that holds your class files:
    C:\>cd \mywork
    Set path to include JDK’s bin.  For example:
    C:\mywork> path c:\Program Files\Java\jdk1.5.0_09\bin;%path%
    Compile your class(es):
    C:\mywork> javac *.java
    Create a manifest file:
    C:\mywork> echo Main-Class: NameOfProject >manifest.txt
    Create a jar file:
    C:\mywork> jar cvfm NameOfProject.jar manifest.txt *.class
    Test your jar:
    C:\mywork> DanceStudio.jar
    

    After creating a jar just double click on it and you are done.

提交回复
热议问题