# 2 threads Processing in Java IDE

**URL:** <https://discourse.processing.org/t/2-threads-processing-in-java-ide/17379>\
**Category:** Coding Questions\
**Created:** [January 27, 2020, 6:37pm UTC](https://discourse.processing.org/t/2-threads-processing-in-java-ide/17379 "2020-01-27T18:37:51Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![gerome](https://avatars.discourse-cdn.com/v4/letter/g/85e7bf/32.png) [@gerome](https://discourse.processing.org/u/gerome)\
**Post date:** [January 27, 2020, 6:37pm UTC](https://discourse.processing.org/t/2-threads-processing-in-java-ide/17379/1 "2020-01-27T18:37:51Z")

</div>

In the course of rebuilding a big Processing project in a Java IDE (IntelliJ) on Windows 10 x64, Processing 3.5.4, I try to translate the old solution for running two Processing threads, one in 2D, one in 3D on different screens:  
The processing code can be found here: [3D renderer not recognized in secondApplet - Processing 2.x and 3.x Forum](https://forum.processing.org/two/discussion/17585/3d-renderer-not-recognized-in-secondapplet#Item_3) (scroll down to the last code version)  
But with my Java code I get error messages in the IntelliJ IDE (see below). I suppose the problem is related to the runSketch method. Could anybody suggest how to solve this?

My Java code:

```auto
import processing.core.PApplet;
import processing.core.PShape;

public class TwoThreads extends PApplet {   
   
    public static void main(String[] args)
    {
        PApplet.main("TwoThreads", args);
    }

    public void settings() {
        size(400, 300, JAVA2D);
        smooth(3);
        noLoop();

        String[] args = {"SecondApplet"};
        SecondApplet sa = new SecondApplet();
        PApplet.runSketch(args, sa);
    }
   
    public void draw()
    {
        line(5, 5, 50, 50);
    }

    public class SecondApplet extends PApplet {
        Tetra tetra;
        float theta;
        public void settings() {
            size(400, 300, P3D);
        }

        public void setup() {
            frameRate(30);
            //PVector myVec = new PVector(width>>1, height>>1, 0300);
            //circle = new MyCircle(this, myVec, #FFFF00);

            tetra = new Tetra(this, 10);
            theta = (float) 0.0;
        }

        public void draw() {

            background(255);
            theta += 0.01;
            translate(width/2, height/2, 0);
            rotateX(theta);
            rotateY(theta);

            // translate the scene again
            translate(100, 100, 20);

            background(0100);
            //translate(mouseX, mouseY, 20);
            //circle.display();
            //translate(mouseX, mouseY, 0);
            tetra.display();
            //box(100);
        }

    }

    public class Tetra {

        final PApplet p;

        // The PShape object
        final PShape gr;
        int t;
        float speed;

        Tetra(PApplet pa, int t_) {
            p = pa;

            t = t_;

            gr = p.createShape();

            gr.beginShape(TRIANGLES);
            gr.fill(150, 0, 0, 127);
            gr.vertex(-t, -t, -t);
            gr.vertex( t, -t, -t);
            gr.vertex( 0, 0, t);

            gr.fill(0, 150, 0, 127);
            gr.vertex( t, -t, -t);
            gr.vertex( t, t, -t);
            gr.vertex( 0, 0, t);

            gr.fill(0, 0, 150, 127);
            gr.vertex( t, t, -t);
            gr.vertex(-t, t, -t);
            gr.vertex( 0, 0, t);

            gr.fill(150, 0, 150, 127);
            gr.vertex(-t, t, -t);
            gr.vertex(-t, -t, -t);
            gr.vertex( 0, 0, t);

            gr.endShape();
        }

        Tetra display() {
            //p.box(100);
            p.shape(gr);
            return this;
        }
    }
}

```

Error messages from IntelliJ IDE:

> java.lang.NoClassDefFoundError: com/jogamp/opengl/GLCapabilitiesImmutable  
> at processing.opengl.PGraphicsOpenGL.createPGL(PGraphicsOpenGL.java:712)  
> at processing.opengl.PGraphicsOpenGL.(PGraphicsOpenGL.java:569)  
> at processing.opengl.PGraphics3D.(PGraphics3D.java:35)  
> at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)  
> at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)  
> at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)  
> at java.lang.reflect.Constructor.newInstance(Constructor.java:423)  
> at processing.core.PApplet.makeGraphics(PApplet.java:2266)  
> at processing.core.PApplet.createPrimaryGraphics(PApplet.java:2345)  
> at processing.core.PApplet.initSurface(PApplet.java:10983)  
> at processing.core.PApplet.runSketch(PApplet.java:10922)  
> at TwoThreads.settings(TwoThreads.java:19)  
> at processing.core.PApplet.handleSettings(PApplet.java:978)  
> at processing.core.PApplet.runSketch(PApplet.java:10897)  
> at processing.core.PApplet.main(PApplet.java:10657)  
> at TwoThreads.main(TwoThreads.java:9)  
> Caused by: java.lang.ClassNotFoundException: com.jogamp.opengl.GLCapabilitiesImmutable  
> at java.net.URLClassLoader.findClass(URLClassLoader.java:382)  
> at java.lang.ClassLoader.loadClass(ClassLoader.java:418)  
> at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355)  
> at java.lang.ClassLoader.loadClass(ClassLoader.java:351)  
> … 16 more  
> java.lang.RuntimeException: com/jogamp/opengl/GLCapabilitiesImmutable  
> at processing.core.PApplet.makeGraphics(PApplet.java:2299)  
> at processing.core.PApplet.createPrimaryGraphics(PApplet.java:2345)  
> at processing.core.PApplet.initSurface(PApplet.java:10983)  
> at processing.core.PApplet.runSketch(PApplet.java:10922)  
> at TwoThreads.settings(TwoThreads.java:19)  
> at processing.core.PApplet.handleSettings(PApplet.java:978)  
> at processing.core.PApplet.runSketch(PApplet.java:10897)  
> at processing.core.PApplet.main(PApplet.java:10657)  
> at TwoThreads.main(TwoThreads.java:9)
> 
> Process finished with exit code 1

---

<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:** [January 27, 2020, 7:28pm UTC](https://discourse.processing.org/t/2-threads-processing-in-java-ide/17379/2 "2020-01-27T19:28:56Z")

</div>

When working outside Processing’s own IDE (PDE) we’ve gotta make sure we’re using Java 8. ⚠

I can’t see what else might be wrong in your code though. 😧

---

<div class="post-metadata">

**Author:** ![gerome](https://avatars.discourse-cdn.com/v4/letter/g/85e7bf/32.png) [@gerome](https://discourse.processing.org/u/gerome)\
**Post date:** [January 28, 2020, 5:41am UTC](https://discourse.processing.org/t/2-threads-processing-in-java-ide/17379/3 "2020-01-28T05:41:58Z")

</div>

I am using java 1.8.0\_421 in the IDE. This I have considered. But thanks for your reply.

---

<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:** [January 28, 2020, 7:34am UTC](https://discourse.processing.org/t/2-threads-processing-in-java-ide/17379/4 "2020-01-28T07:34:21Z")

</div>

> [@gerome](#):
>
> _java.lang.NoClassDefFoundError: com/jogamp/opengl/GLCapabilitiesImmutable_

The error above states it couldn’t find the definition for GLCapabilitiesImmutable:  
[JogAmp.org/deployment/jogamp-next/javadoc/jogl/javadoc/com/jogamp/opengl/GLCapabilitiesImmutable.html](http://JogAmp.org/deployment/jogamp-next/javadoc/jogl/javadoc/com/jogamp/opengl/GLCapabilitiesImmutable.html)

It means the OpenGL 3D library JogAmp isn’t in the compiler’s classpath (-cp) option: [JogAmp.org](http://JogAmp.org)

> **[Home](https://techmonitor.ai/)**
>
> Data-driven insight and authoritative analysis for business, digital, and policy leaders in a world disrupted and inspired by technology

---

<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:** [January 28, 2020, 1:39pm UTC](https://discourse.processing.org/t/2-threads-processing-in-java-ide/17379/5 "2020-01-28T13:39:38Z")

</div>

> [@gerome](#):
>
> java.lang.NoClassDefFoundError

Are you sure you’ve imported all dependencies?

---

<div class="post-metadata">

**Author:** ![gerome](https://avatars.discourse-cdn.com/v4/letter/g/85e7bf/32.png) [@gerome](https://discourse.processing.org/u/gerome)\
**Post date:** [January 29, 2020, 9:35am UTC](https://discourse.processing.org/t/2-threads-processing-in-java-ide/17379/6 "2020-01-29T09:35:44Z")

</div>

Yes I forgot to add the jogl jar files in the project. I downloaded the [JOGL files](https://jogamp.org/deployment/jogamp-current/archive/) resp. [jogamp-all-platforms.7z](https://jogamp.org/deployment/jogamp-current/archive/jogamp-all-platforms.7z) Following this [install description](https://jogamp.org/wiki/index.php?title=Downloading_and_installing_JOGL) for Win 64bit I need at least the following 4 files:

- gluegen-rt.jar
- jogl-all.jar
- gluegen-rt-natives-windows-amd64.jar
- jogl-all-natives-windows-amd64.jar

I put these files into a folder in my project folder and try to set the dependency to it following these [instructions for intelliJ] (Ecllipse, Netbeans are described there as well)([https://jogamp.org/wiki/index.php/Setting\_up\_a\_JogAmp\_project\_in\_your\_favorite\_IDE](https://jogamp.org/wiki/index.php/Setting_up_a_JogAmp_project_in_your_favorite_IDE)). But the jar files don´t show up under external libraries resp. seem to be not identified as valid classes. Hm…

---

<div class="post-metadata">

**Author:** ![gerome](https://avatars.discourse-cdn.com/v4/letter/g/85e7bf/32.png) [@gerome](https://discourse.processing.org/u/gerome)\
**Post date:** [January 29, 2020, 9:38am UTC](https://discourse.processing.org/t/2-threads-processing-in-java-ide/17379/7 "2020-01-29T09:38:20Z")

</div>

Processing is quite comfortable and I forgot the dependencies for running it in a Java IDE.

---

<div class="post-metadata">

**Author:** ![gerome](https://avatars.discourse-cdn.com/v4/letter/g/85e7bf/32.png) [@gerome](https://discourse.processing.org/u/gerome)\
**Post date:** [January 30, 2020, 7:06am UTC](https://discourse.processing.org/t/2-threads-processing-in-java-ide/17379/8 "2020-01-30T07:06:16Z")

</div>

Now after choosing the JOGL jars in IntelliJ from the Processing (program files) folder the error message disappeared after running the code. But now there is another error:

> java.lang.RuntimeException: java.lang.ClassNotFoundException: TwoThreads\_2  
> at processing.core.PApplet.runSketch(PApplet.java:10852)  
> at processing.core.PApplet.main(PApplet.java:10657)  
> at org.processing.twoThreads\_2.TwoThreads\_2.main(TwoThreads\_2.java:10)  
> Caused by: java.lang.ClassNotFoundException: TwoThreads\_2  
> at java.net.URLClassLoader.findClass(URLClassLoader.java:382)  
> at java.lang.ClassLoader.loadClass(ClassLoader.java:418)  
> at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355)  
> at java.lang.ClassLoader.loadClass(ClassLoader.java:351)  
> at processing.core.PApplet.runSketch(PApplet.java:10845)  
> … 2 more

I found many posts about this problem concerning IntelliJ´s IDE specific reasons e.g. [here](https://stackoverflow.com/questions/17300318/error-classnotfoundexception-in-intellij-idea/17300613#17300613)

---

<div class="post-metadata">

**Author:** ![gerome](https://avatars.discourse-cdn.com/v4/letter/g/85e7bf/32.png) [@gerome](https://discourse.processing.org/u/gerome)\
**Post date:** [January 30, 2020, 8:20am UTC](https://discourse.processing.org/t/2-threads-processing-in-java-ide/17379/9 "2020-01-30T08:20:44Z")

</div>

ok now after building this anew it runs. The case was the dependency from the JOGL files all to find in the processing installation library folder together with the core.jar.

Thanks for the helpful feedback!

---

<div class="post-metadata">

**Author:** ![neilcsmith](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/neilcsmith/32/144_2.png) [@neilcsmith](https://discourse.processing.org/u/neilcsmith)\
**Post date:** [January 30, 2020, 10:06am UTC](https://discourse.processing.org/t/2-threads-processing-in-java-ide/17379/10 "2020-01-30T10:06:16Z")

</div>

> [@GoToLoop](#):
>
> When working outside Processing’s own IDE (PDE) we’ve gotta make sure we’re using Java 8. ⚠

Only if you’re on macOS, and mostly workaround-able if you are.

> [@gerome](#):
>
> Yes I forgot to add the jogl jar files in the project. I downloaded the [JOGL files](https://jogamp.org/deployment/jogamp-current/archive/) resp

I would copy the JOGL files from inside a Processing install or from [processing/core/library at master · processing/processing · GitHub](https://github.com/processing/processing/tree/master/core/library) - some things might be patched, which may or may not be relevant.
