1

so i am just trying eclipse with processing and are having a problem with getting the java application to run.

I am basically following this tutorial: https://processing.org/tutorials/eclipse/

I have followed the steps but when i get to this part:

    import processing.core.PApplet;

    public class UsingProcessing extends PApplet{

public static void main(String[] args) {
    PApplet.main("UsingProcessing");

}

}

No errors or nothing but when i press run (run as java application), a java program opens (no window, i can just see the program in the bottom part of the screen). Then it closes after a couple of seconds.

I also get the following errors:

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:10707)
at processing.core.PApplet.main(PApplet.java:10504)
at processing.core.PApplet.main(PApplet.java:10486)
at UsingProcessing.main(UsingProcessing.java:6)
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

That part of code should at least give me an empty sketch but i get nothing..

This guy got it to work but i cant.. https://www.youtube.com/watch?v=0cqSjyvA8EY

I can assure you that i have imported the processing library correct, so that is not where the problem lays. I believe that it is some problem with my java? I am using a macbook pro and the following java:

Java(TM) SE Runtime Environment 18.3 (build 10.0.1+10)

Java HotSpot(TM) 64-Bit Server VM 18.3 (build 10.0.1+10, mixed mode)

Thankful for all the help and I am kind of new to this so please be gentle if anything is wrong!

EDIT:

I have also tried with IntelliJ without luck, the same thing, java opens for a brief moment and then closes. This video was my guide: https://www.youtube.com/watch?v=_h2GZgnPcnM

zejton
  • 11
  • 4
  • Is eawt package available as a library? If not, you will need to add it, or use a package manager like maven to get it working. – Compass Jun 12 '18 at 17:26
  • I am not sure what you mean by this sorry, i have imported the "core.jar" and built the path so that it is compiled – zejton Jun 12 '18 at 17:32
  • Did you ever get this figured out? – Kevin Workman Dec 03 '18 at 21:19
  • yep, i had to choose an "core.jar" that was a version **older**. I think it was java 10 or 11 (I am not sure at all). Also I believe I had to use an older version of Processing and lose all the functions of the newer version. Maybe I'll look into this more in the future ! Thanks for you interest ! – zejton Dec 05 '18 at 10:27
  • I don't remember fully if I had to use a older java version, but I am sure that an older version of Processing was needed for it to work with Eclipse – zejton Dec 05 '18 at 10:29

2 Answers2

2

I can assure you that i have imported the processing library correct, so that is not where the problem lays.

You need more than just the core.jar library. In your case you need whatever .jar file contains the com/apple/eawt/QuitHandler class.

This answer says that the .jar you're looking for comes with the Mac JDK. Try adding that .jar file to your classpath.

Kevin Workman
  • 41,537
  • 9
  • 68
  • 107
  • Hey! thanks for the answer. I am sure that i have the right JDK as well. Can you give me some insight on how to find the .jar file? I have looked for it but am not able to find it.. – zejton Jun 13 '18 at 07:32
  • So i downloaded the ui.jar file from http://www.java2s.com/Code/Jar/m/Downloadmacuijar.htm . And when i add this to the classpath in eclipse it does nothing.. – zejton Jun 13 '18 at 07:45
  • And another thing, their tutorial says that i only need the "core.jar" library... Thanks for the help man – zejton Jun 13 '18 at 08:57
  • @zejton From Processing's perspective you only need the `core.jar` library. But you're on a Mac, which has its own weird Java rules. All my information is coming from googling your error and seeing what other people have done in the past. It sounds like you shouldn't download anything, but the `.jar` file should be inside your JDK directory. – Kevin Workman Jun 13 '18 at 15:57
  • what is the jar file's name?? – zejton Jun 13 '18 at 17:24
  • @zejton The answer I linked lists a few `.jar` file names. – Kevin Workman Jun 13 '18 at 17:27
0

So i believe the problem is sort of solved. The problem was (i think) with the java that apple uses(?). So i downgraded to the Processing 2 core.jar and everything worked fine.

Found here: https://github.com/processing/processing/issues/5371

and a link that i did not fully understand : https://github.com/processing/processing/wiki/Supported-Platforms#java-9

The guy there suggests that you should downgrade your jdk(?), but I think that it was processing 2 that was discussed (when i did that it did not work). So for now, everything in eclipse done with processing has to be done with processing 2.

This is strange because the tutorial on processings website made it work with processing 3

EDIT: the previous answer was asked more than five years ago..

zejton
  • 11
  • 4