Step1. Create a java project in Eclipse under Windows
// HtmlUnit.java
package com.some.HtmlUnit;
public class HtmlUnit {
public static void main(String[] args) {
// ...
}
}
The project's Java Build Path links multiple jars in a certain folder.
After the test is normal, proceed to the next step.
Step2. Copy java/jar to Linux
2-1. Copy java
For example /some/path/ com/some/HtmlUnit /HtmlUnit.java
The bold part must be consistent with the java package
2-2. Copy all related jars
For example, copy to /some/path2/htmlunit-3.3.0/lib/
Step 3. Compile under the command line
cd /some/path/
javac -cp "/some/path2/htmlunit-3.3.0/lib/*" com/some/HtmlUnit/HtmlUnit.java
// Note that they correspond to the previous colors.
//The compiled HtmlUnit.class will be in the same folder as java
Step 4. Execute from the command line
java -cp $CLASSPATH:"/some/path2/htmlunit-3.3.0/lib/*":. com/some/HtmlUnit/HtmlUnit
// Of course, you must deploy java on Linus in advance. This is basic knowledge so that $CLASSPATH will have value. I won’t go into details here.