zoukankan      html  css  js  c++  java
  • 制作java可执行程序的方法

    命令行方法:

    1、 创建Manifest.txt文件,内容:

    Main-Class: com.mkyong.awt.AwtExample

    2、打包所有的class,包括Manifest.txt文件:

    $ jar -cvfm run.jar Manifest.txt com/

    3、run.jar即可在windows下双击鼠标执行(前提是要安装jre)。在linux用命令行执行:

    $ java -jar run.jar

    IDE方法:

    用eclipse

    1、右键点击工程,选择 export... 菜单:

          Create an Executable File from Eclipse Step 2.jpg

    2、选择 java 下面的 Runnable JAR file:

           Create an Executable File from Eclipse Step 3.jpg

    3、在launch configuration里选择包含main函数的类

           Create an Executable File from Eclipse Step 4.jpg

          

      1.   Extract required libraries into JAR - Extracts the actual .class files from the libraries your app uses and puts those .class files inside the runnable JAR. So, the runnable JAR will not only contain the .class files of your application, but also the .class files of all the libraries your application uses.

      2.   Package required libraries into JAR - Puts the actual JAR files of the libraries into your runnable JAR. Normally, a JAR file within a JAR file cannot be loaded by the JVM. But Eclipse adds special classes to the runnable JAR to make this possible.

      3.   Copy required libraries into sub folder next to JAR - Keeps the library JARs completely separate from the runnable JAR, so the runnable JAR will only contain the .class files of your application.

        一般情况下,选择2.

    4、用launch4j可以给程序定制图标等东西。

    打包好的jar文件,可以用 jar tf run.jar 查看其中的内容

  • 相关阅读:
    SAX解析XML笔记
    使用 Angular 2 来创建FlexGrid控件
    算法-快速排序(优雅版)
    使用泛型简化动态代理
    Java泛型概述
    POI-PPT官方文档
    Java 利用POI操作PPT
    Java8学习笔记(九)--日期/时间(Date Time)API指南
    Java8学习笔记(八)--方法引入的补充
    Android WebView加载本地html并实现Java与JS交互
  • 原文地址:https://www.cnblogs.com/welhzh/p/3555099.html
Copyright © 2011-2022 走看看