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 vary depending on the Eclipse version.
- Choose the Java file from Project Explorer or Navigator view.
- Right-click (a 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 the "export" option.
Select the ".jar" file option and click the "Next" button.
Select the "Java classes to be included" for the JAR file and click the "Next" button.
Click the "Next" button.
Select the "Main class" and click 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 method "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");
}
}