1
import processing.core.PApplet;

public class Main {

    public static void main(String[] args) {
        PApplet.main(new String[]{TheApp.class.getName()});
            }

}

And here is the error:

Exception in thread "main" java.lang.Error: Unresolved compilation problem: 
    PApplet cannot be resolved
George Profenza
  • 50,687
  • 19
  • 144
  • 218
  • 1
    This error indicates that compiler can't see the required class `PApplet`. You must make sure that library containing this class is accessible (located on the classpath, or included into Maven's pom.xml or similar) – Nikolai Shevchenko Jul 13 '22 at 10:20
  • @SaiAungHlyanHtet what IDE are you using (if any) ? – George Profenza Jul 13 '22 at 11:10

1 Answers1

1

You need to add Processing's core.jar library to your java projects build path / class path.

You should be able to find core.jar where Processing is installed/unzipped, inside the core/library folder.

Your IDE should have an option to add paths to .jar files (otherwise you can use the -cp flag in command line)

(The above should hold true for the default JAVA2D renderer and without other libraries. For P2D/P3D you'll need gluegen/jogl libraries, for serial you'll need serial.jar as well jssc java and native (JNI) libs, etc.)

George Profenza
  • 50,687
  • 19
  • 144
  • 218
  • thank you for your answer. I use Eclipse. I added Processing's core.jar library to my project's build path. And the error is still remained. – Sai Aung Hlyan Htet Jul 14 '22 at 11:09
  • interesting. and that is when you try to run the java project within eclipse (not export an application from eclipse that you try to run from commandline outside of eclipse), right ? – George Profenza Jul 15 '22 at 20:17
  • Did you get errors listed in the Problems tab in eclipse ? FWIW I've uploaded a test eclipse project [here](https://lifesine.eu/so/P5TestsBK.zip). – George Profenza Jul 15 '22 at 23:45