1

Got a quick little question. This past week, I've been working on some Java projects on my windows PC at home using Processing for the graphics. I've been using the ItelliJ IDE to add the processing library to the project, and it's been working just fine.

Today however, I was away from home, and wanted to try and see if I could work on my MacBook as well. I went through the same steps for downloading the IntelliJ IDE and Processing, and adding Processing to the project. But this time after I try to run my program, I keep getting "java.lang.NoClassDefFoundError" errors.

I made a small trial program that should just make the box to draw in and a small circle inside the box, but the same error occurs. The line it points to as the error is where I declare the PApplet.main("Classname");

I'm unsure if this is just a Mac problem, or if there's something else I have to do that I didn't have to on my windows PC. But if you can help shed some light on what could be causing this problem, that'd be greatly appreciated.

This is the little test program I made that should just draw a circle to the screen. The consul showed a java.lang.noClassDefFoundError at the one line in the main method.

import processing.core.PApplet;

public class Test extends PApplet
{
    public static void main()
    {
        PApplet.main("Test");
    }

    public void setup() {}
    public void settings()
    {
         size(300, 300);
    }

    public void draw()
    {
         ellipse(150, 150, 50, 50);
    }
}

This is the Error message I received:

java.lang.NoClassDefFoundError: com/apple/eawt/QuitHandler
    at java.base/java.lang.Class.getDeclaredMethods0(Native Method)
    at java.base/java.lang.Class.privateGetDeclaredMethods(Class.java:3119)
    at java.base/java.lang.Class.getMethodsRecursive(Class.java:3260)
    at java.base/java.lang.Class.getMethod0(Class.java:3246)
    at java.base/java.lang.Class.getMethod(Class.java:2065)
    at processing.core.PApplet.runSketch(PApplet.java:10855)
    at processing.core.PApplet.main(PApplet.java:10650)
    at processing.core.PApplet.main(PApplet.java:10632)
    at Test.main(Test.java:7)
Caused by: java.lang.ClassNotFoundException: com.apple.eawt.QuitHandler
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:582)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:190)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:499)
    ... 9 more

SOLUTION EDIT: So after a ton more searching and posting to a few other forums, I got my answer. IntelliJ was defaulting to JDK 10, which apparently doesn't like this. So I downloaded the JDK 8 and set that as the default for IntelliJ, as well as changed the language level in the Modules tab down to 8, and now it works like a charm. Thank you to all those who tried to help.

BAT754
  • 11
  • 2
  • What class is it saying it can't find? Is your `Test` class in a package? – Kevin Workman May 30 '19 at 21:51
  • It is not in a package, and I'm not quite sure that is says which class it can't find. I'll update the question with a screen shot of the error message – BAT754 May 30 '19 at 21:53
  • People generally prefer it if you post the text of error message (that way we can copy and paste it into google). But it looks like the error is indeed Mac related. I'd check that you have the native libraries included on your classpath? – Kevin Workman May 30 '19 at 21:57
  • Oh okay, that makes more sense. This is the first time I've had to post my own question, so I'll keep that in mind from now on. And I'll check that. It doesn't sound like something I did yet – BAT754 May 30 '19 at 22:02
  • Your code looks fine. It's probably something with Mac, but unfortunately that's where my knowledge ends. Best I can suggest is to update Java and make sure the native libraries are also added to your classpath. Normally you don't need those for basic stuff, but maybe Mac is more particular. – Kevin Workman May 30 '19 at 22:04
  • It probably is. Macs always seem to be a little more picky. Thanks for the help – BAT754 May 30 '19 at 22:07
  • Please see https://stackoverflow.com/a/42660624/104891. – CrazyCoder May 30 '19 at 22:30

0 Answers0