javaeclipseprocessingpapplet

java.lang.NoClassDefFoundError for papplet


I'm having issues getting processing set up. I have another project I pulled that uses it perfectly well, but when I try to create a new project, I keep running into errors. I have all my libraries set up, and I'm using processing 3.5.4, although I've also tried the most recent version. Everything is added to the build path, so I don't understand why PApplet isn't being found enter image description here

    Error: Could not find or load main class                 embodiedInteractionDance.MovingRectangle
    Caused by: java.lang.NoClassDefFoundError: processing/core/PApplet

upon going to run configurations and clicking "show command line"

    C:\Users\user\.p2\pool\plugins\org.eclipse.justj.openjdk.hotspot.jre.full.win32.x86_64_17.0.9.v20231028-0858\jre\bin\javaw.exe
    -Dfile.encoding=UTF-8
    -Dstdout.encoding=UTF-8
    -Dstderr.encoding=UTF-8
    -p "C:\Users\user\eclipse-workspace\embodiedInteractionDance\libs\core.jar"
    -classpath "C:\Users\user\eclipse-workspace\embodiedInteractionDance\bin;C:\Users\user\eclipse-workspace\embodiedInteractionDance\libs\gluegen-rt.jar;C:\Users\user\eclipse-workspace\embodiedInteractionDance\libs\jogl-all.jar;C:\Users\user\eclipse-workspace\embodiedInteractionDance\libs\MidPose.jar;C:\Users\user\eclipse-workspace\embodiedInteractionDance\libs\gluegen-rt-natives-windows-amd64.jar;C:\Users\user\eclipse-workspace\embodiedInteractionDance\libs\jogl-all-natives-windows-amd64.jar;C:\Users\user\eclipse-workspace\embodiedInteractionDance\libs\jogl-all-noawt-2.2.4.jar"
    -XX:+ShowCodeDetailsInExceptionMessages embodiedInteractionDance.MovingRectangle

am I correct to understand that this is an issue with the core jar? I've cleared out all existing run configs and tried again, same error

MovingRectangle

package embodiedInteractionDance;
import processing.core.*;

public class MovingRectangle extends PApplet{
// The argument passed to main must match the class name
public static void main(String[] args) {
    PApplet.main(MovingRectangle.class.getName());
}

// method used only for setting the size of the window
public void settings(){
    size(400,400);   
   
}

// identical use to setup in Processing IDE except for size()
public void setup(){
    background(0);
    stroke(255);
    strokeWeight(10);
}

// identical use to draw in Processing IDE
public void draw(){
    line(0, 0, 500, 500);
}}

UsingProcessing

package shapes;
import processing.core.PApplet;
public class UsingProcessing extends PApplet {

//  Canvas canvas = new Canvas();
//  JFrame overlay = new JFrame("Mouse Listener");
public static void main(String[] args) {
    PApplet.main(UsingProcessing.class.getName());
    //      canvas.addMouseListener();
}
public void settings(){
    size(1000,1000);
}

public void setup(){
    strokeWeight(1);
    //moved the static objects from draw() to here
    //hair
    fill(0);
    ellipse(width/7*4, height/7, width-100, 350);
    rect(width/7, 200, width-100,height);

    //head
    fill(210,180,140);
    ellipse(height/2+50,width/2+50,height-100,width-100);
    //eyes
    fill(0); 
    ellipse(width/3,height/3,100,100);
    ellipse(width/3*2,height/3,100,100);

}

public void draw(){

    //pupils (leave them growing, fun effect)
    fill(120,50,240);
    stroke(0);
    ellipse(width/3,height/3,second(),second());
    ellipse(width/3*2,height/3,second(),second());
    
    //nose
    stroke(255, 102, 0);
    strokeWeight(5);
    noFill();
    curve(width/2, height/2-50, width/2, height/2+100, width/2+50, height/2+100, width/2+75, height/2+150);

    //eyebrows
    fill(175,50,75);
    triangle(width/4, height/4, width/4, height/4+50,  width/4+150, height/4+50 );
    triangle(width/4*3-150, height/4, width/4*3-150, height/4+50,  width/4*3+100, height/4+50 );

    //mouth
    fill(255,50,100);
    stroke(200,50,50);
    arc(width/2, height/3*2, width/3*2-width/3, second(), 0, PI, CHORD);

}}

Solution

  • According to the command line, your core.jar is on the modulepath (-p), not on the classpath (-classpath). This might be a problem as a JAR on the module path is treated as a separate encapsulated module. In contrast, all your other JARs are on the classpath and therefore treated as a single unencapsulated module, the so-called unnamed module.

    In Project > Properties: Java Build Path tab Libraries, move core.jar from the Modulepath to the Classpath via drag and drop.