建立文件
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文件