Move the Java project in eclipse to run under Linux

Source: Internet
Author: User
Tags scp command

Some Java projects need to be run under a Linux system, taking into account the performance requirements or the need to invoke shell scripts. Completing the Java project in eclipse to a Linux system requires some action:

1, the Java project under the eclipse of the source package into a jar, there are two ways, but it is recommended that the first to facilitate the management of the associated jar package.

Method 1: Use Maven

1) Ensure that the Java project is a MAVEN project, and that the associated jar packages are in Lib and are introduced into. Classpath and Pom.xml.

2) Right-click the project->debug->debug configurations, select the current project in base directory, enter the-P project name package in goals, tap Debug. The project name will be generated under the target directory. jar and project name-sources.jar file.

Method 2: Package through eclipse

Select the project right-click->export->jar ... Step by step, finally become 1.jar, and then add some additional jar packages, such as Lucene, Mysql-connecor some jar package also packaged into a 2.jar (finally easy to use), upload to the server (command scp-r-pxx port number [email Protected]/.... Then enter the password, note the port number before the p to capitalize, the oblique rod later you want to put the uploaded jar package path.

2. Package the entire project into a zip file

3. Upload the packaged zip file to the remote Linux server (via Xshell or SCP command)

4. Unzip the zip file in the Linux server

5. Use the command CP target/project name. Jar Lib, copy the jar package under Target to Lib

6. Running the project

Method One: Write start.sh script, use java-server-xms2048m-xmx2048m com.test.rds.CreateDbTest in script, load Main method class, run./start.sh

Method Two: First to execute the Javac, to generate a. class file. The format is as follows: javac-cp/home/username/. /1.jar:/home.username/. /2.jar Main Method Class Java

And thenFor the generated class file execution: Java -cp/home/username/. /1.jar:/home.username/. /2.jar: Main Method Class( Note: If the class file has a package name, such as Package.test, it should be:java -cp/home/usern ame/. /1.jar:/home.username/. /2.jar:package.test)

Move the Java project in eclipse to run under 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.