how to….Executable jar File
Hướng dẫn tạo file jar khả thi, double click là chạy như file exe
download Demo
1> tao ung dung mau nhu sau:
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class FormDemo extends JPanel
{
public FormDemo()
{
add(new JLabel(“Label ne”));
add(new JTextField(20));
add(new JButton(“Button day”));
}
public static void main(String args[])
{
JFrame f= new JFrame();
f.setContentPane(new FormDemo());
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setTitle(“Dong goi ung dung java -> executable jar file”);
f.pack();
f.setVisible(true);
}
}
2> compile: javac FormDemo.java
3> tao thu muc META-INF
4> tao file MANIFEST.MF nam trong thu muc META-INF
dong so 1: Manifest-Version: 1.0
dong so 2: Created-By: 1.6.0_05 (Sun Microsystems Inc.)
dong so 3: Main-Class: FormDemo
dong so 4:
(dong so 4 la 1 dong trong)
5> jar cvMf Demo.jar META-INF *.class
Luu y:
buoc 4:
- sau main-class: phai co 1 khoang trang
- duoi dong main-class phai co 1 dong trang
buoc 5:
- tuy chon nay: cvmf khong the tao ra file thuc thi
- tuy chon dung de tao file thuc thi jar: cvMf
* Neu class nam trong 1 package thi sao? vi du: FormDemo nam trong com.app.jguru
1. bien dich: javac -d . FormDemo.java
2. sau khi bien dich se phat sinh thu muc com
3. file MANIFEST.MF: Main-Class: com.app.jguru.FormDemo
4. build jar: jar cvMf Demo.jar META-INF com
Chưa có phản hồi.
-
Gần đây
-
Liên kết
-
Lưu trữ
- Tháng Sáu 2008 (26)
- Tháng Năm 2008 (2)
- Tháng Tư 2008 (15)
- Tháng Ba 2008 (32)
-
Chuyên mục
-
RSS
RSS của bài viết
RSS của phản hồi