Creating a JAR file with Eclipse
These instructions are only a guide for creating a JAR based on a single .java file.
Take it as an introduction.
The following steps may change depending on the Eclipse version.
- Choose the Java file from Project Explorer or Navigator view.
- Right-click (the contextual menu will be shown) and choose "Export".
- Choose Java -> JAR file.
- Select the destination folder, for example C:\openkm-dev\jar\your-class.jar.
- Click Next.
- Click Next.
- Optional step. If your Java class implements "public static void main(String[] args)" , then you must choose your Java class as the entry point.
- Click Finish.
Images
Select the file to be exported as a JAR. Right-click and select "Export" option.
Select ".jar" file option and click on the "Next" button.
Select the "Java classes to be included" in the JAR file and click on the "Next" button.
Click the "Next" button.
Select the "Main class" and click on the "Finish" button.
If your Java class implements "public static void main(String[] args)" , then you must choose your Java main class as the entry point; otherwise you can skip this step.
Sample JAR file
Requisites:
- Must implement the class "public static void main(String[] args)".
package com.openkm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class Test {
private static Logger log = LoggerFactory.getLogger(Test.class);
public static void main(String[] args) {
System.out.println("Test sample");
}
}