Porting from Processing IDE to Eclipse
Hi all,
I am porting a little project I did in Processing PDE (Processing.org) into Eclipse because I want to use full Java functionalities. For those who dont know Processing is a Java based language...pratically speaking it consists of libraries to build 2D/3D interactive graphics and animations.
The processing.core package contains all processing classes, and I 've imported and built it within my Eclipse project. The PApplet class is the one that contains most of functionalities of Processing. Here is a link with documentation Generated Documentation (Untitled) .
Now in the Processing PDE when I create multiple classes, they are all treated as "inner classes," meaning they are not individual entities unto themselves, but rather are classes inside of the larger PApplet. This is causing lot of confusion for me now and I don't know how to treat and link all classes together.
It would br great if someone could have a look and explain me how to correct all errors I get. This is the project file with all classes and libraries http://www.designedbyenergy.com/site/myproject.zip
In addition, one thing that is not clear to me is to make a global variable accessible to all classes within the Project. Where do I declare global variables? How can I access them from all classes?
thanks
Re: Porting from Processing IDE to Eclipse
Quote:
a global variable accessible to all classes within the Project
If you must have global variables, put them all in a class as static and have static methods to get them and to set them.
To access a global: <type> valueOfVar = GlobalClass.getGlobalVar1();
where <type> is the data type: int, String etc
To set: GlobalClass.setGlobalVar1(valueToSave);
Java has inner classes. Can you explain your problem with a small simple example.
Re: Porting from Processing IDE to Eclipse
Thanks for the insight about global variables.
As for the problems Im having now with Eclipse is very simple...lots and lots of unexplicable errors..such as
Clearly I am mistaking how my classes access method from Processing libraries..I guess...
Exception in thread "Animation Thread" java.lang.NoClassDefFoundError: javax/media/opengl/glu/GLUtessellatorCallback
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Unk nown Source)
at java.lang.Class.getConstructor0(Unknown Source)
at java.lang.Class.getConstructor(Unknown Source)
at processing.core.PApplet.makeGraphics(Unknown Source)
at processing.core.PApplet.size(Unknown Source)
at processing.core.PApplet.size(Unknown Source)
at Main.setup(Main.java:60)
at processing.core.PApplet.handleDraw(Unknown Source)
at processing.core.PApplet.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: javax.media.opengl.glu.GLUtessellatorCallback
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 11 more
Re: Porting from Processing IDE to Eclipse
Quote:
NoClassDefFoundError: javax/media/opengl/glu/GLUtessellatorCallback
The JVM can not find the named class.
Where is the above class's class file? Are you missing a jar file on the classpath?
Re: Porting from Processing IDE to Eclipse
I see...probably I need to import more jar files..but then how do I know I loaded all needed libraries in my code? is there a way to import them all without typing one by one?
Re: Porting from Processing IDE to Eclipse
If the classes are all in the same folder you can use a wildcard: the *
import java.awt.*;
This won't get classes from java.awt.event
You'll need an import for that:
import java.awt.event.*;
1 Attachment(s)
Re: Porting from Processing IDE to Eclipse
Mhhhh it s going to be full headaches..
imported now in the project all opengl related jar files (dont what processing actually uses but I found them inside the processing opegl library folder). The selected files you see in the attached image are jar files .
They are all in the same folder...but how call them to import in my code?
import XXXX?
sorry for crap questions
Re: Porting from Processing IDE to Eclipse
Quote:
how call them to import
Two places to put references to class files:
One: put all jar files on the classpath for the javac and java commands
Two: add import statements to the source for the javac command to use when searching the jar files for classes.
You can use a zip utility to open a jar file and see its contents.
Re: Porting from Processing IDE to Eclipse
I am not sure I got what you mean
I added these line in my source code
import javax.media.opengl.*;
import javax.media.opengl.glu.*;
but still have many errors...at least I found the missing class GLUtessellatorCallback
Exception in thread "Animation Thread" java.lang.UnsatisfiedLinkError: no jogl in java.library.path
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.loadLibrary0(Unknown Source)
at java.lang.System.loadLibrary(Unknown Source)
at com.sun.opengl.impl.NativeLibLoader.loadLibraryInt ernal(NativeLibLoader.java:189)
at com.sun.opengl.impl.NativeLibLoader.access$000(Nat iveLibLoader.java:49)
at com.sun.opengl.impl.NativeLibLoader$DefaultAction. loadLibrary(NativeLibLoader.java:80)
at com.sun.opengl.impl.NativeLibLoader.loadLibrary(Na tiveLibLoader.java:103)
at com.sun.opengl.impl.NativeLibLoader.access$200(Nat iveLibLoader.java:49)
at com.sun.opengl.impl.NativeLibLoader$1.run(NativeLi bLoader.java:111)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.opengl.impl.NativeLibLoader.loadCore(Nativ eLibLoader.java:109)
at com.sun.opengl.impl.windows.WindowsGLDrawableFacto ry.<clinit>(WindowsGLDrawableFactory.java:60)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at javax.media.opengl.GLDrawableFactory.getFactory(GL DrawableFactory.java:106)
at processing.opengl.PGraphicsOpenGL.allocate(Unknown Source)
at processing.core.PGraphics3D.setSize(Unknown Source)
at processing.core.PApplet.makeGraphics(Unknown Source)
at processing.core.PApplet.size(Unknown Source)
at processing.core.PApplet.size(Unknown Source)
at Main.setup(Main.java:63)
at processing.core.PApplet.handleDraw(Unknown Source)
at processing.core.PApplet.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Re: Porting from Processing IDE to Eclipse
You need to put the jar files on the classpath for both the javac command when you compile the code and for the java command when you execute the code.
Re: Porting from Processing IDE to Eclipse
Thanks for your patience.
so adding jar files for my libraries and importing them in my code is not enough? How do I check I have both classpath for javac command and java command?
Re: Porting from Processing IDE to Eclipse
Sorry, I do NOT know how to use your IDE.
My IDE uses command lines that I configure for compiles and executions.
I manually add the -classpath jar1.jar;jar2.jar;... etc to the commandline.
Re: Porting from Processing IDE to Eclipse
To place the jar on your classpath in eclipse right click the project and go to properties. Select 'java build path' -> libraries -> Add External Jar. Within Eclipse you should then be able to compile and run the code.