If you want to make .jaras .exe double-click to run it, you need to write a mainfest. MF file.
And
Main-class: Specifies the entry class for the attribute.
If eclipse exists at hand, specify main class when generating. jar, and eclipse will automatically generate related files.
Next we will Package a test project that I just wrote into test. Jar. I hope it will help you.
The following structure is available to open test. jar with WinRAR:
Test. Jar
META-INF
Manifest. MF
Jframe. Class
Jframe. Java
Java code?
12345678910111213141516171819202122 |
import javax.swing.JFrame; public class jFrame extends JFrame{ /** * @param args */ public jFrame() { super ( "Hello World" ); setSize( 800 , 600 ); setVisible( true ); } public static void main(String[] args) { // TODO Auto-generated method stub jFrame frame= new jFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } } |
Manifest. MF content:
Manifest-version: 1.0
Main-class: jframe