歡迎您光臨本站 註冊首頁

將java程序打包成「可執行」文件示例

←手機掃碼閱讀     火星人 @ 2014-03-26 , reply:0

建立文件
C:\JarTest\T\InputDialogDemo.java 內容
QUOTE:
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文件

[火星人 ] 將java程序打包成「可執行」文件示例已經有420次圍觀

http://coctec.com/docs/linux/show-post-189238.html