# Running a Processing 4 PApplet in Eclipse IDE

**URL:** <https://discourse.processing.org/t/running-a-processing-4-papplet-in-eclipse-ide/44792>\
**Category:** Libraries\
**Created:** [July 21, 2024, 4:58pm UTC](https://discourse.processing.org/t/running-a-processing-4-papplet-in-eclipse-ide/44792 "2024-07-21T16:58:27Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ignotus](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/ignotus/32/14922_2.png) [@Ignotus](https://discourse.processing.org/u/Ignotus)\
**Post date:** [July 21, 2024, 4:58pm UTC](https://discourse.processing.org/t/running-a-processing-4-papplet-in-eclipse-ide/44792/1 "2024-07-21T16:58:27Z")

</div>

I’ve been developing a library for Processing 4 in the Eclipse IDE, using the Processing Library Template. It would be handy to test a PApplet within the library, rather that running it in Processing. However, I can’t get my code to run, even this very basic example:

```auto
package net.paulhertz.pixelaudio;
import processing.core.PApplet;

public class TestPixelAudio extends PApplet {

	public void setup() {
		size(1024, 1024);
	}
	
	public void draw() {
		
	}

	public static void main(String args[]) {
		PApplet.main(new String[] { "--present", "TestPixelAudio" });
	}
}

```

My problem seems to be the following:

> java.lang.UnsupportedClassVersionError: processing/core/PApplet has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 52.0

I am not running the Ant script to compile a library, just compiling with “Build All” in the Project menu, apparently with success. The library build works just fine.

I’ve compiled with JRE 17, but it would seem that I need a more recent version for the current version of Processing 4.0. What should that be?

I suppose that in the long run, I should try to use this template in IntelliJ IDEA [https://github.com/processing/processing-library-template-gradle](https://github.com/processing/processing-library-template-gradle), but Eclipse has been my go-to IDE for a long time.

cheers,

Paul

---

<div class="post-metadata">

**Author:** ![micycle](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/micycle/32/201_2.png) [@micycle](https://discourse.processing.org/u/micycle)\
**Post date:** [July 21, 2024, 6:05pm UTC](https://discourse.processing.org/t/running-a-processing-4-papplet-in-eclipse-ide/44792/2 "2024-07-21T18:05:10Z")

</div>

Looks like its using actually Java 8 (class v52).  
If your project is certainly using 17, then the problem might be the run config pointing to Java 8.

Example:

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/d/0/d003e39419eb6317a4ec2f78f50be7997753787c.png)

---

<div class="post-metadata">

**Author:** ![quark](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/quark/32/26_2.png) [@quark](https://discourse.processing.org/u/quark)\
**Post date:** [July 21, 2024, 8:09pm UTC](https://discourse.processing.org/t/running-a-processing-4-papplet-in-eclipse-ide/44792/3 "2024-07-21T20:09:26Z")

</div>

> [@Ignotus](#):
>
> ```auto
> public void setup() {
> size(1024, 1024);
> }
> 
> ```

Need to use settings in Eclipse

```auto
    public void settings() {
		size(1024, 1024);
	}

    public void setup() {
		// Normal stup code stuff
	}

```

---

<div class="post-metadata">

**Author:** ![Ignotus](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/ignotus/32/14922_2.png) [@Ignotus](https://discourse.processing.org/u/Ignotus)\
**Post date:** [July 21, 2024, 8:54pm UTC](https://discourse.processing.org/t/running-a-processing-4-papplet-in-eclipse-ide/44792/4 "2024-07-21T20:54:14Z")

</div>

I was configuring Eclipse and the build path to use Java 17. I must have missed something.

I think checking Java 1.8 compatibility, even though I was compiling with 17, may have caused problems. With that unchecked, I am not getting the same error – that’s a plus. However, now Eclipse lodges a java.lang.ClassNotFoundException. Odd, considering that I am looking at the .class file in the bin directory where it ought to be. But at least a step in the right direction, I think.

Added the settings() method, too.

thanks,

Paul

---

<div class="post-metadata">

**Author:** ![Ignotus](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/ignotus/32/14922_2.png) [@Ignotus](https://discourse.processing.org/u/Ignotus)\
**Post date:** [July 21, 2024, 9:26pm UTC](https://discourse.processing.org/t/running-a-processing-4-papplet-in-eclipse-ide/44792/5 "2024-07-21T21:26:03Z")

</div>

I still get a FileNotFoundException even with a fully qualified path:

> java.lang.RuntimeException: java.lang.ClassNotFoundException: /Users/paulhz/Code/Workspace/PixelAudio/bin/net/paulhertz/pixelaudio/TestPixelAudio  
> at processing.core.PApplet.runSketch(PApplet.java:10074)  
> at processing.core.PApplet.main(PApplet.java:9845)  
> at net.paulhertz.pixelaudio.TestPixelAudio.main(TestPixelAudio.java:20)  
> Caused by: java.lang.ClassNotFoundException: /Users/paulhz/Code/Workspace/PixelAudio/bin/net/paulhertz/pixelaudio/TestPixelAudio  
> at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)  
> at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)  
> at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)  
> at processing.core.PApplet.runSketch(PApplet.java:10067)  
> … 2 more

I’m trying to run my code as a Java Application. I think that’s the only choice, since Applets are no longer supported.

You can see from the error message that TestPixelAudio.main is actually being called by PApplet. The Run Configuration points to net.paulhertz.pixelaudio.TestPixelAudio, which seems correct to me.

The repository is here: [https://github.com/Ignotus-mago/PixelAudio](https://github.com/Ignotus-mago/PixelAudio).

// Paul

---

<div class="post-metadata">

**Author:** ![Ignotus](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/ignotus/32/14922_2.png) [@Ignotus](https://discourse.processing.org/u/Ignotus)\
**Post date:** [July 21, 2024, 10:51pm UTC](https://discourse.processing.org/t/running-a-processing-4-papplet-in-eclipse-ide/44792/6 "2024-07-21T22:51:34Z")

</div>

Solved. If the PApplet child is in a package, you need to include the package reference:

```auto
	public static void main(String args[]) {
		PApplet.main(new String[] { "net.paulhertz.pixelaudio.TestPixelAudio" });
	}

```

Thanks again @quark and @micycle, you comments were spot on:

– For Processing 4, make sure all relevant build path settings use Java 17  
– Use the settings() method to set window width and height

Also check out @quark’s suggestion in [post #9](https://discourse.processing.org/t/running-a-processing-4-papplet-in-eclipse-ide/44792/9):

> [@quark](#):
>
> ```auto
> public class TestPixelAudio extends PApplet {
> 
> public static void main(String[] args) {
> PApplet.main(new String[]{TestPixelAudio.class.getName()});
> }
> 
> ```

// Paul

---

<div class="post-metadata">

**Author:** ![micycle](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/micycle/32/201_2.png) [@micycle](https://discourse.processing.org/u/micycle)\
**Post date:** [July 21, 2024, 11:12pm UTC](https://discourse.processing.org/t/running-a-processing-4-papplet-in-eclipse-ide/44792/7 "2024-07-21T23:12:50Z")

</div>

I tend to use the .main() method signature that takes a `.class` object, rather than string name. It helps to avoid this kind of problem (and will continue to work if you rename the class).

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [July 21, 2024, 11:28pm UTC](https://discourse.processing.org/t/running-a-processing-4-papplet-in-eclipse-ide/44792/8 "2024-07-21T23:28:17Z")

</div>

My fav has always been PApplet.**runSketch()**, which accepts an array of strings w/ options such as " --sketch-path", and a PApplet instance as its 2nd argument:

[https://Processing.GitHub.io/processing-javadocs/core/processing/core/PApplet.html#runSketch-java.lang.String:A-processing.core.PApplet-](https://Processing.GitHub.io/processing-javadocs/core/processing/core/PApplet.html#runSketch-java.lang.String:A-processing.core.PApplet-)

---

<div class="post-metadata">

**Author:** ![quark](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/quark/32/26_2.png) [@quark](https://discourse.processing.org/u/quark)\
**Post date:** [July 22, 2024, 2:32pm UTC](https://discourse.processing.org/t/running-a-processing-4-papplet-in-eclipse-ide/44792/9 "2024-07-22T14:32:17Z")

</div>

I have used Eclipse (since 2009) for developing several Processing libraries and I have found the following strategy works for me.

A minimum of _two_ Eclipse projects  
**Project 1**  
This contains the source code , resources, ant scripts etc. to build the library.

**Project 2.**  
This project contains all the tests, experiments and demo sketches used while developing the library.

In both projects the library path will be linked to any necessary Processing jars .

In project 2 we don’t link to our library jar rather we link to the actual library project. This makes debug mode and stepping through code so much more useful as it just slips into the library code.

My favourite way of coding main is

```auto
public class TestPixelAudio extends PApplet {

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

```

This has two benefits

1. the package name is included in the class name when using `getName()`
2. Changing the class name through refactoring will automatically update the `main()` method

---

<div class="post-metadata">

**Author:** ![Ignotus](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/ignotus/32/14922_2.png) [@Ignotus](https://discourse.processing.org/u/Ignotus)\
**Post date:** [July 22, 2024, 3:34pm UTC](https://discourse.processing.org/t/running-a-processing-4-papplet-in-eclipse-ide/44792/10 "2024-07-22T15:34:48Z")

</div>

> [@quark](#):
>
> `new String[]{TestPixelAudio.class.getName()}`

Nice. I already had the stub of a separate project.  
I added my library project to its classpath and now can use it from the test project.

 ![Screenshot 2024-07-22 at 10.33.14 AM](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/5/3/53fc0ae004fad81c10faf3ca8600b8d88b836050.png)

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [July 22, 2024, 4:17pm UTC](https://discourse.processing.org/t/running-a-processing-4-papplet-in-eclipse-ide/44792/11 "2024-07-22T16:17:32Z")

</div>

An example of using **runSketch()** in the PDE in order to have a separate PGraphics on a separate thread:

> [@Problems when trying to draw to a P3D PGraphics when called from a thread?](https://discourse.processing.org/t/problems-when-trying-to-draw-to-a-p3d-pgraphics-when-called-from-a-thread/6301/4):
>
> Although it’s pretty much a hack, here’s the workaround I’ve come up w/: crazy_face /\*\* \* Threaded PGraphics II (v1.0.1) \* GoToLoop (2018/Dec/07) \* \* https://Discourse.Processing.org/t/ \* problems-when-trying-to-draw-to-a-p3d-pgraphics- \* when-called-from-a-thread/6301/4 \* \* https://Forum.Processing.org/two/discussion/25799/ \* how-to-draw-a-rect-in-a-thread#Item\_2 \*/ static final int W = 250, H = 200, FPS = 10; Layer layer; void settings() { size(W, H, JAVA2D); smooth(3); } v…

We config ARGS\_SKETCH\_FOLDER " --sketch-path" to match PApplet’s main sketch, so save functions know the root folder where the sketch is run:

```auto
final String[] switches = { ARGS_SKETCH_FOLDER + sketchPath(), "" };
runSketch(switches, layer = new Layer());

```

Layer is the 2nd PApplet subclass:

```auto
public static class Layer extends PApplet {
  static final short INTERVAL = 1*1000, TXT_SIZE = 40;
  static final float BOLD = 2.5;
  static final color BORDER = 0, TXT_COLOR = -1;

  PGraphics pg;
  PImage img;

  void settings() {
    size(1, 1, P2D);
  }

```

---

<div class="post-metadata">

**Author:** ![LangdonS](https://avatars.discourse-cdn.com/v4/letter/l/ebca7d/32.png) [@LangdonS](https://discourse.processing.org/u/LangdonS)\
**Post date:** [July 23, 2024, 9:13pm UTC](https://discourse.processing.org/t/running-a-processing-4-papplet-in-eclipse-ide/44792/12 "2024-07-23T21:13:29Z")

</div>

You can easily convert Processing code to Java with the export project button.  
(Cntl+Shift+E or command+shift+E)

---

<div class="post-metadata">

**Author:** ![babiji](https://avatars.discourse-cdn.com/v4/letter/b/df788c/32.png) [@babiji](https://discourse.processing.org/u/babiji)\
**Post date:** [November 22, 2024, 7:50pm UTC](https://discourse.processing.org/t/running-a-processing-4-papplet-in-eclipse-ide/44792/13 "2024-11-22T19:50:54Z")

</div>

Thank you! i’ve been trying to configure Processing with Apache Batik (for parsing complex SVGs) and I just haven’t been able to get both of them to work together for days 😭. This was the missing piece that got it working 😀
