ProcessingEclipse
Search:
ClassWork / ProcessingEclipse

Eclipse Is Very Powerful

  • Environment trumps language. So many people are so hot on arguing the virtues of their favorite languages but I think the text editor for your coding is more important. For example Java is kind of an uptight language but Eclipse can fill in the tedious extra typing and strict typing of languages like Java. Best of all it basically tells you what is wrong with your code and offers to fix it for you.
  • But Eclipse has gotten kind of daunting. Even knowing what to download at eclipse.org has gotten very complicated. Click on the big yellow "Get Started Now.. Download Eclipse" button in the upper right. You want Eclipse IDE for Java Developers or Eclipse Classic. Note you don't want J2EE.
  • After you start it up and get rid of the welcome screen, you might be put off by hundreds pulldown options and thousands of sub options. Luckily you can get started by just knowing a few options and have the rest of them fall one by one as gift to you as you continue using the environment.
    1. Create a New Project: File>New>Java Project, Name it.
    2. Create a New Program within that Project: Right (control) click on new project New>Class Name it.
    3. Write Your Code: (much more on this soon)
    4. Run it Right (control) click on the class and pull down to "run as" Until you change the code to something runnable (app or applet) you won't get interesting choices here.

Editing Processing in Eclipse, the best of both worlds.

  • The Eclipse program you downloaded is ready to deal with Java. Java is a pain, Processing is great. Because Processing is just a collection of java classes (now that we we are not using the processing text editor) Eclipse can deal with it .
  • The problem is that Eclipse has never heard of processing and doesn't know where to find those classes. This is a common problem in object oriented coding where you try not to start from scratch but instead build on top of other people's classes.
  • Eclipse is easily able to point at the external resources you need (in this case the processing files). Right (control) click on the project, pull down to Properties>Java Build Path>Libraries>Add External Jar and hunt down (with Processing 1.0 on the mac, you have to control click on the Processing app and choose "Show Package Contents") Processing/Lib/core.jar . That is it. Now eclipse knows all about Processing.
  • Now you have to tell your code to use processing by including this line at the top public class MyProgram extends PApplet{ and a matching } at the end. Whatever you put for MyProgram must match the name of the file. Using Eclipse you are in the big world of Java but by saying extends PApplet you have located yourself in the pleasant locality of Processing with access all the stuff you already know how to use.
  • You can start in now with writing Processing as you normally would. If you start copying and pasting your old processing programs in you will notice that there is one small change needed. Instead of void setup() you have to say public void setup()
  • You might start noticing the little red dot in the left margin. These are problems with your code. If you mouse over them you get the problem. If you click on them you get solutions. If you click on the solutions it fixes your problems. Beat that.
  • Now you are working in Java you are sadly obliged to put import statements at the top of your code for all the classes you intend to use. Here is the first in a long line of gifts from Eclipse. Source>Organize Imports looks through your code and automatically puts in the correct imports.

Video in Processing in Eclipse

  • So far we were talking about regular Processing in Eclipse. But remember that the Capture object is part of the video library which is technically a library not part of Processing itself (but as a "core" library it gets downloaded with it). So you need to go back into Right (control) click on the project, pull down to Properties>Java Build Path>Libraries>Add External Jar and this time hunt down (with Processing 1.0 on the mac, you have to control click on the Processing app and choose "Show Package Contents")Processing/Libraries/video.jar so Eclipse knows about the video library.
  • It is hard for an applet which is design to work in the secured confines of a web browser to get a hold of some of the more interesting hardware on your machine. This was the case with Serial and it is the case again with Capture. With capture it may work sometimes but not always. Anyway the simple answer is to run your Processing as an Application by adding a function like below (don't forget to change YourClassName to your class name). Now when you go to "run as" you will have two choices Applet and Application.
       static public void main(String _args[]) {
           PApplet.main(new String[] { "YourClassName" });
       }
Search
  Page last modified on February 04, 2009, at 12:20 PM