.Jarcan be run by double-clicking like .exe.

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.