Java Project package runs under CMD or Linux

Source: Internet
Author: User

Java Project package runs under CMD or Linux

1. Run under CMD

Export the project into a jar package in Eclipse and unzip it with the compression software

After decompression, enter the project root directory in CMD and run the program:

  Oracle2redis-jar>java-cp. \lib\*; Oracle.xxx.xx.cn.ReadOracle2Redis

2. Running in Linux

Upload the extracted folder to the Linux system and run it in the project root directory:

  Java-cp./lib/*: Oracle.xxx.xx.cn.ReadOracle2Redis (unlike Windows under Path delimiter (\ vs/) and Terminator (; vs:)

PS:

I need to read the database table in time increments, so read the SEQ value in the config file before reading the data, mark the number of rows that have been read, and then record the current read line number seq in the file after reading the increment data.

Using ResourceBundle to read the SEQ value in the configuration file, the class searches for the configuration file at the root of the project and then reads the data inside it.

The configuration file created in eclipse in the SRC directory, eclipse will automatically create the bin folder in the project root directory at compile time, and copy the configuration file to the Bin folder. When the code is running, search for the configuration file under the Bin folder first. This means that the configuration file in the Bin directory will be read first, and if the write configuration file is written to a profile in the SRC directory, it will cause the read/write not the same file.

Then someone would ask why not read and write the configuration files in the bin directory at the same time, because the bin folder will not be created when eclipse exports the jar package, so no.

So when writing the file should go to the SRC directory of the configuration file (in Eclipse debugging will be read and write inconsistencies, reading the bin directory, written in the SRC directory), so that when running the jar package read and write are the same file (jar package of wood has bin directory, is used in the SRC), There is no case that the file cannot be found.

Java Project package runs under CMD or Linux

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.