I still feel like using the Eclipse Third-party plugin Fatjar directly package the Java project into a jar, upload it directly to the server (Execute permission), and refer to an article about Plug-ins. The methods below (some relevant information and practices on the Web) are troublesome and prone to error.
1. First in eclipse to export the project source into a jar package, you can select the project right key->export->jar. Step by step, finally become 1.jar, and then add some additional jar packages, such as Lucene, Mysql-connecor some of the jar package also packaged into a 2.jar (finally easy to use), upload to the server (command scp-r-pxx port number Username@xxx/..... Then enter the password, note that the port number before p to uppercase, oblique pole the path that you want to put on the uploaded jar package; 2. In addition, you also want to put your source code main class file (contains main function, such as Test.java) also uploaded to the server (place the location of the casual, remember good);
3. Implementation. To execute the Javac first, generate the. class file. The format is as follows:
javac-cp/home/username/.. /1.jar:/home.username/.. /2.jar Test.java
4. For the generated class file. Perform
java-cp/home/username/.. /1.jar:/home.username/.. /2.jar:test
Note: If the class file has a package name, such as Package.test, it should be:
java-cp/home/username/.. /1.jar:/home.username/.. /2.jar:package.test
The last colon can not be less ~ ~ ~
The Java project is made into a jar package, but the Third-party jar package is not included in the package, and when the jar package is run on the command line, there is an exception that cannot be found by the class.
The solution on the web is to put the Third-party jar packages into the JDK's Extended Class folder (%java_home%/jre/lib/ext),
To run again, or the same error, my Java project to invoke the Webservice,webservice project also used the same jar package,
When you start the server, the webservice is not properly deployed, which should be a conflict between the jar packages in the WebService project and the jar packages in the JDK.
By constant experimentation, it finally succeeded.
1, the new folder test is located in D disk;
2. Put all the Third-party jar packages used in the folder Lib, and then put the Lib under test;
3, the exported Java Project jar Package A.jar also put under test;
4, modify the Project Jar Package Meta-inf folder MANIFEST.MF configuration file:
manifest-version:1.0
Main-class:cn.golaxy.yqpt.client.main.gathermain
Class-path:lib/soapmonitor-1.5.jar
Lib/spring-aop.jar
Specify the package path for the main function (note: Add a space after the colon).
Write all of the jar packages that are referenced after Class-path (note: To write a branch, not to write a jar package, as long as it is not too long to ensure that the line, otherwise, there will be exception in thread "main" java.io.IOException: Line too long
At Java.util.jar.Attributes.read (attributes.java:356)
At Java.util.jar.Manifest.read (manifest.java:167)
At Java.util.jar.manifest.<init> (manifest.java:52)
At Java.util.jar.JarFile.getManifest (jarfile.java:158)
Exception, add two spaces before changing lines, and finally a carriage return.
5, will revise the MANIFEST.MF document to cover off the original;
6. Execute JAR Package at command line: Java-jar A.jar.
Enough detail, hope can help you O (∩_∩) o haha ~
The
should be noted for running Java Engineering on a Linux server.
1: On Linux:/etc/profile set classpath Configure the correct jar path.
2: The local Java project into a jar package. For example: 1.jar
3: Upload the Java project included jar packs and the jar packages in step 2 to the development directory. such as 2.jar
Run java-classpath/usr/javalib/1.jar:/usr/javalib/2.jar Java class
For example: if the/etc/ Profile set
Export classpath=.: $JAVA _home/lib/dt.jar: $JAVA _home/lib/tools.jar:/home/caojh/lib/ Commons-lang-2.2.jar:/home/caojh/lib/junit.jar:
can omit-classpath.
Note: Projects in eclipse need to be made into a single jar package.