Using Eclipse to create and use an executable jar file

Source: Internet
Author: User

I recently wrote a small program of stock yield analysis in Java to calculate the benefits of my stock operation. Here, a procedure is recorded to package the source code into an executable command.

1: Generate the executable jar file
Select the project, select Export from the menu, select runnable JAR file, and then, depending on the situation, select the Export method for the third-party library, then you can, I choose the package required Libraries into generated JAR, In this case, the resulting jar file will contain the third-party library files required by the program, and no additional classpath will be required on the subsequent command line.
2: Run the jar file in the Windows Environment script script
Create a new batch file, enter
Java-jar Stockearningsapp_v1.0.1.jar%1%2
This command means: Run the Stockearningsapp_v1.0.1.jar file in the current directory,%1 and%2 are the parameters that are required for the program to run, and these parameters originate from the command-line arguments of the script.

configuration file and directory structure
The operation of the program requires a configuration file, and my program determines that the configuration file needs to be placed under "current path".
InputStreamReader InputStreamReader = new InputStreamReader (New FileInputStream ("Config.properties"), encoding);

This means that you need to create a subdirectory in the current directory stock, which is used to save files generated during program processing
String outputFile = new String ("Stock\\stock_exchange_all.txt");

Using Eclipse to create and use an executable jar file

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.