Daniel's Processing in Eclipse tutorial no longer works

Hi everyone,

I am trying to set up Eclipse for Processing and I followed Daniel's Processing in Eclipse tutorial on the website. But the sample code doesn't compile anymore in Eclipse. I do realize that the tutorial is for Processing 1.1+ and I am using 3a5. But I was wondering whether anyone has figured out what needs to be changed?

Below is the link to the tutorial. https://www.processing.org/tutorials/eclipse

And I basically followed it step by step and pasted the following code into Eclipse.

import processing.core.*;

public class MyProcessingSketch extends PApplet {

  public void setup() {
    size(200,200);
    background(0);
  }

  public void draw() {
    stroke(255);
    if (mousePressed) {
      line(mouseX,mouseY,pmouseX,pmouseY);
    }
  }
}

Eclipse shows a warning message that says "The serializable class MySketch does not declare a static final serialVersionUID field of type long" which I don't really understand what it means.

If anyone can help I would really appreciate it.

Thanks, Frank

Comments

  • You can ignore this warning. In fact you can ignore all warnings in Eclipse and still run the sketch, what you can't do is ignore errors.

    I can see nothing in the code that would generate an error.

    The name of the class MUST match the name of the file. I notice that the message says 'MySketch' but the class is called 'MyProcessingSketch' :-?

  • More pedantic: Name of the public top-class gotta match ".java"'s file name where it resides. :-B

  • Thanks quark and GotoLoop for your help. I checked the points both of you said and updated the project files and code to make sure everything matches but I still get the same error message. For the project, I am using JavaSE-1.6 as the JRE System Library. Does this matter?

  • Newest Processing versions are finally using Java 7! B-)

  • I guess I need to find out how to get Eclipse to corporate with Java 7. ;)

  • Before configuring Eclipse to use a chosen Java version, it gotta exist 1st!
    Why don't you install latest Java SE 8u31 from the link below?
    http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

  • I have Java SE 8u31 installed already. I have started to look at how to set it up. It seems tricky. Thank you for your help GoToLoop!

  • edited February 2015

    As I said that the serializable message is a warning, it will NOT stop the sketch code above from compiling and running. If your code doesn't compile/run then something else is wrong. The Java version you are using will have not change the fact you get this warning.

    Check the output in the Eclipse console for any messages.

  • Hi quark,

    Thank you for your help. I was able to resolve the build path problem by change the JRE library back to 1.6. And now the project does not have any errors. But it still has this warning message says that "The serializable class HelloWorldApp does not declare a static final serialVersionUID field of type long" which I have no idea of what's causing it. When I run it below is the error message I see.

    Exception in thread "main" java.lang.UnsupportedClassVersionError: HelloWorldApp : Unsupported major.minor version 51.0 at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClassCond(ClassLoader.java:637) at java.lang.ClassLoader.defineClass(ClassLoader.java:621) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141) at java.net.URLClassLoader.defineClass(URLClassLoader.java:283) at java.net.URLClassLoader.access$000(URLClassLoader.java:58) at java.net.URLClassLoader$1.run(URLClassLoader.java:197) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:190) at java.lang.ClassLoader.loadClass(ClassLoader.java:306) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:247)

    And I am still investigating what's causing it.

    Thanks again for your help.

    -Frank

  • You need to google 'Java serialization'

    Probably the most common use of serialization is to save objects to disc. When an object is serialized it saves the object state (the values stored in the objects field) and information about the objects class. This can be deseriazed later to retrieve the object in its previous state.

    If you save an object and then modify the class then it cannot be deserialised and throws an error. It is possible to generate a serial version ID which is a hash value created from the class source code, this can be used to test whether an object can be deserialized using the current version of the class.

    To get rid of the warning click on the yellow symbol to the left of the class line and either select the suppress warning option. Alternatively you can also create the serial version ID from the Eclipse menus, but you have to regenerate it everytime you modify the class source code.

    This happens because your class inherits from PApplet which inherits from Applet which implements the Serializableinterface.

  • I finally found time to figure out what was wrong. It's a stupid mistake. I didn't have JDK 8 installed on my Mac. After installed the latest JDK 8 from Oracle's website. Everything in the tutorial worked perfectly. Thanks both @quark and @GoToLoop for your help.

Sign In or Register to comment.