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 is, an introduction.

The following steps can be changed depending on the new Eclipse version changes.

  1. Choose the Java file from Project Explorer or Navigator view.
  2. Do right click ( will be shown contextual menu ) and choose "export".
  3. Choose Java -> JAR file.
  4. Select the destination folder, for example C:\openkm-dev\jar\your-class.jar.
  5. Click Next.
  6. Click Next.
  7. Optional step. If your java class implements "public static void main(String[] args)" then you must choose your java class as the class of the entry point.
  8. Click Finish.

Images

Select the file to be exported as a jar. Right-click on the mouse and select "export" option.

Select ".jar" file option and click on "next" button.

Select the "JAVA classes to be included" into the jar file and click on "next" button.

Click on "next" button.

Select the "Main class" and click on "Finish" button.

If your JAVA class implements "public static void main(String[] args)" then you must choose your java Main class as the class of 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");
    }
}