UTF.COM.CN

将java程序打包成“可执行”文件示例

作者:佚名 | 来源:网络 | 添加时间:2007-03-18 12:06:42 | 人气:1837

将java程序打包成“可执行”文件示例

----摘抄
建立文件
C:\JarTest\T\InputDialogDemo.java 内容
package T;

import javax.swing.JOptionPane;
public class InputDialogDemo {
    /** Main method */
    public static void main(String[] args){
        // Prompt the user to enter a year 
        String yearString = JOptionPane.showInputDialog(null,"Enter a year", "Input (int)", JOptionPane.QUESTION_MESSAGE);
    }
}
编译成InputDialogDemo.class
建立文件
C:\JarTest\manifest.mf内容
Manifest-Version: 1.0
Created-By: xyz
Main-Class: T.InputDialogDemo

在C:\JarTest输入命令 jar cvfm test.jar manifest.mf T
需要注意的是:
1. T必须与包名一致(包括大小写);
2. The manifest file name and the archive file name needs to be specified in the same order the 'm' and 'f' flags are specified. 

这样就会生成test.jar,双击就会运行。
这样后就可以使用exe4j等打包成exe文件
责任编辑:冬天来了
【字号: 】【去论坛讨论】【发表评论】【打印本文】【告诉好友】【关闭窗口

姓名:

验证码: 点击刷新