Eclipse exports executable java project / executable jar files (including third-party jar packages)

Eclipse exports executable java project / executable jar files (including third-party jar packages)

Elder martial brother has deployed a new virtual machine, which will be launched in the new semester! Before, because the crawler code was unstable, it was always run directly with eclipse, and then modified when there were problems. But this is troublesome, and eclipse itself takes up a lot of memory. Fall! So this afternoon, I deleted the previous code, which is helpful for many frustrated systems out. Println replaces log4j. The path and database connection are processed with configuration files. Finally, they are made into executable jars, so that they can play a big role in the new virtual machine^_^ Y

BIU ~ after talking nonsense, get to the point. There are various methods to package Java projects into executable jars. There are many examples on the Internet, such as configuring manifest files. In fact, the simplest and feasible method is to export runnable jar files directly with eclipse.

My version of eclipse is indigo service release 1 (it seems to be the legendary 3.7, uncertain)

1. First, right-click your Java project, select export, and select runnable jar file under the Java folder, as shown in the following figure:

2. After selecting runnable jar file, a dialog box as shown below will pop up. After selecting the export path, the default is finish. However, two points should be noted:

The JVM parameters you set in run configuration will no longer work after the package is completed. You need to specify them on the command line when executing jar (see 4);

There are three processing methods for the third-party packages since. In fact, no matter which one will not affect your use, I use the first one by default. He will decompress the third-party jar packages since and put them into Src.

3. After finishing, the executable jar package is generated. If your project contains configuration files, such as conf / XX Properties, then create the conf directory in the directory on the same layer as the jar package, and put XX in the conf directory Properties, as shown in the following figure:

4. Finally, run the packaged jar file, execute the start Java command on the command line and specify the JVM parameters, such as setting the initial allocated memory of 128M and the maximum memory of 256M:

start java -Xmx256m -Xms128m -jar spider. jar

In the figure above, we can see that there is a run Bat file. In fact, there is only one line of command in this file: start Java - xmx256m - xms128m - jar spider Jar, so you can double-click to execute jar. When you need to change the startup parameters, just edit run Bat is OK.

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

Thank you for reading, hope to help you, thank you for your support to this site!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>