Java Program package with BAT file Execution __java

Source: Internet
Author: User

The most recent time in the project to do is to use a Java program packaged with a bat file to perform this function. On the Internet to find some methods, in order to meet the requirements, need to be in the process of execution, pop-up command Prompt window and not close. So one of the following methods is used.

1, the first is to package the Java source code into an executable jar file. This process can be done with myeclipse. Packaged as a double click on the executable jar file, you need to use the Fatjar plug-in (Eclipse use). Download Address:

http://sourceforge.net/project/showfiles.php?group_id=115990&package_id=125924

After the installation method decompression, the net.sf.fjep.fatjar_0.0.24 folder under the Plugins folder is copied to the plugins under the MyEclipse installation directory, and then the MyEclipse is restarted. This tool makes it easy to package the project in MyEclipse into a jar file.

The steps are: your project =〉build Fat Jar

To make an executable jar, be careful to select the main class. Next

To select a jar package contained in the program, the packaged jar cannot be executed. Finish,ok, you can export the executable jar package.

2. Execute jar file with bat file. Create a new Notepad file, change the suffix name to bat, open with a text editor, and write the following command:


XXX is the name of the jar file you packed out. Note that bat files and jar files are placed in the same directory.

Finally save, double-click the bat file execution, you can. To stop running, just close the line.

Exception in thread "main" Java.lang.noclassdeffounderror:hello,classpath is not configured when an error similar to the following occurs.

Classpath for  .; E:\j2sdk1.4.2_04\lib\dt.jar; E:\j2sdk1.4.2_04\lib\tools.jar
Path is E:\j2sdk1.4.2_04\bin;
Java_home for E:\Java\j2sdk1.4.2_04
Classpath his path before must be a bit and semicolon   .;  That's it..

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.