Error message: Usage: PApplet

I am working only since a short time with Processing. I always get this error message:

Usage: PApplet <appletname>

For example I am using these 2 Java-files in a project:

Main.java:

`package de.hpi.javaide.firststeps;
import processing.core.PApplet;
public class Main {
    public static void main(String[] args) {
        PApplet.main(new String[]{"--present", "de.hpi.javaide.firststeps.Game"});
    }
}
`

Game.java:

package de.hpi.javaide.firststeps; import processing.core.PApplet; @SuppressWarnings("serial") public class Game extends PApplet { @Override public void setup() { noStroke(); fill(255, 10, 10); rectMode(CORNER); rect(5, -100, 20, 10); } @Override public void draw() { } }

These files come from a course of OpenHPI. Last year processing worked without any problem. Now I get the above shown error code when using any java file using process.

I am using eclipse neon, java version "1.8.0_161" and core.jar (version 3)

Any help appreciated! Thanks in advance for your help!

Answers

  • edited April 2018

    I suspect the problem is that the source code you are working with is written for Processing 2. With Processing 3 and Eclipse Neon you Game class should look like this

    public class Game extends PApplet {
    
      // You will need to modify the parameters for your sketch
      public static void main(String args[]) {
        PApplet.main(new String[] { Game.class.getName() });
      }
    
      // This method is reqd for P3 and external IDEs like Eclipse  
      public void settings(){
        size(400,300, P2D);
      }
    
      public void setup(){
        // Usual stuff here except size() that is in settings()
      }
    
      public void draw(){
        background(0);
        // usual stuff here
      }
    
      // rest of the class
    
  • Answer ✓

    Thank You very much for Your answer. I suspected this also as a cause of my problem. But the solution of the problem was, taht when clicking 'Run' in eclipse You have to configure 'Run' and select 'Main.java'. When clicking 'Run' 'PApplet.java' is used, for what reason ever. Doing so using 'stup()' and not 'settings()' it works nevertheless. Thanks for Yout quick support. I have learned some new things.

Sign In or Register to comment.