Create jar file from sketch in java

A more stable way to work is to use maven, then your not reliant on ide. Further I would expect your sketch to look like this:-

package main.com.test;
import processing.core.PApplet;


public class MyMain extends PApplet {
     public void settings() {
        size(500, 500);
    }

    public void draw(){
        background(64);
        ellipse(mouseX, mouseY, 20, 20);
    }

  static public void main(String[] passedArgs) {
    String[] appletArgs = new String[] { "main.com.test.MyMain" };
    if (passedArgs != null) {
      PApplet.main(concat(appletArgs, passedArgs));
    } else {
      PApplet.main(appletArgs);
    }
  }
}

Note the package name prefix in appletArgs. Now processing does not officially release maven artifacts, which is unfortunate, but there’s nothing stopping you creating your own (core.jar would be a start). The latest version available from maven central is 3.3.7 which might be good enough.
See snippet below showing part of pom.xml to create a main manifest using maven.

  <plugin>
        <artifactId>maven-jar-plugin</artifactId>
        <version>3.2.0</version>
        <configuration>
          <archive>
            <manifest>
              <addClasspath>true</addClasspath>
              <mainClass>main.com.test.MyMain</mainClass>
            </manifest>
          </archive>
        </configuration>
      </plugin>
1 Like