Java project exported as executable jar package and run __ function under Windows/linux

Source: Internet
Author: User
Tags gc overhead limit exceeded
Java project exported as Jar package, project file structure:


Create a new file in the root directory of your project: MANIFEST.MF and a Lib folder (the file folder is in a Third-party package). The contents of the file are as follows:

manifest-version:1.0
Main-class:test. Deltamakeindextest (Here you need to make the corresponding modifications according to the class of the main function, package name. Class name format)
Class-path:././lib/sqljdbc.jar./lib/ikanalyzer3.2.3stable.jar/lib/lucene-analyzers-3.5.0.jar./lib/ Lucene-core-3.6.0.jar (List all the Third-party packages used)
(There is also a blank line here)
For specific MANIFEST.MF How to write can refer to this blog: http://soulshard.iteye.com/blog/346453


Then start the project in the form of a jar bag.




After that, put the Lib folder with the third party jar package and the jar bag I just brought out below the same level.

In Windows, you can write a run.bat file, the content of Java-jar Wip.jar, open cmd CD to switch to the directory where the jar package, running run.


If you are in Linux, you can write a run.sh file and set the permissions to run, the content is Java-jar Wip.jar, the same CD switch to the directory of the jar package, run./run.sh.


If you encounter a Outofmemoryerror:java heap space error, you can set the parameters-xms512m-xmx1024m
-xms <size>
Set JVM initialization heap memory size
-xmx <size>
To set the maximum heap memory size for the JVM


If you encounter Java.lang.OutOfMemoryError:GC overhead limit exceeded error

Parameters can be set-xx:-usegcoverheadlimit

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.