How does a Java program generate a Jar execution file (2), javajar

Source: Internet
Author: User

How does a Java program generate a Jar execution file (2), javajar
I. UseEclipseProductionJarFile

Note: This method can be used to package a project containing a third-party jar package.

1. Right-click your Java project, select Export, and select Runnable JAR file in the Java folder, as shown in:

2. After you select Runnable JAR file, the following dialog box is displayed. After you select the export path, Finish by default. However, note the following two points:

  • The JVM parameter you set in the run configuration does not take effect after it is packaged. You need to specify it in the command line when executing the jar (see figure 4 );
  • There are three processing methods for third-party packages. No matter which one does not affect your use, I use the first one by default, he will decompress the third-party jar package and put it in src.

3. after the jar package is generated, the executable jar package is generated. If your project contains a configuration file, such as conf/xx. properties, create the conf directory in the directory at the same layer as the jar package, and put xx in the conf directory. properties, as shown in:

4. Finally, run the packaged jar file. Execute the start java command in the command line and specify the JVM parameters. For example, set the initial memory allocation to 128 MB, and the maximum value is 256 MB:

Start java-Xmx256m-Xms128m-jar spider. jar

In, we can see that there is a run. bat file, which actually contains only one line of command: start java-Xmx256m-Xms128m-jar spider. jar, and then double-click it to execute the jar. When you need to change the startup parameters, you only need to edit run. bat.

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.