Eclipse exports executable Java projects/executable jar files (including third-party jar packages)

Source: Internet
Author: User

Senior brother has deployed a new virtual machine. This is a new term! Previously due to CrawlersCodeIt is unstable, so it is always run directly with eclipse, and then modified when problems occur. But this is troublesome, and eclipse occupies a lot of memory! So this afternoon, I removed the previous code, which is frustrating for many systems. out. println replaces log4j. The path, database connection, and configuration file are used for processing. Finally, it is compiled into an executable jar. In this way, the new VM can be used.

Biu ~ After talking nonsense, I entered the topic. There are various methods to package the Java project into executable jar, and there are many examples on the Internet, such as how to configure manifet files. In fact, the simplest and most feasible method is:Export runnable JAR file directly using eclipse.

My eclipse version is Indigo Service Release 1 (it seems to be the legendary 3.7, not sure)

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:

 
StartJava-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.

 

Well, it's a mark process. In fact, it's very simple. When I don't know it, I need to check the information and try again. It's a waste of time. :)

 

 

Related Article

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.