简体   繁体   中英

running a processing applet in eclipse

I have downloaded and installed the processing IDE from their official website, then I followed the instructions on how to import the libraries into eclipse. I have core.jar, gluegen-rt.jar and jogl-all.jar added to path. I have the code below which I'm trying to run but when I go to the run menu there is no run options whatsoever. I only see 'run configurations'. Is there anything I'm missing?

package week2;
import processing.core.*;

public class ProcessingTest extends PApplet{

    private String URL = "https://c2.staticflickr.com/6/5254/5428199232_c3678ed2ac.jpg";
    private PImage backgroundImg;

    public void setup()
    {
        size(800,  800);
        backgroundImg = loadImage(URL, "jpg");
        backgroundImg.resize(800, 800);
        background(backgroundImg);
    }
    public void draw()
    {

    }
    //public static void main(String args[]){
    //  PApplet.main(new String[]{"--present", "week2.ProcessingTest"});
    //}
}

As of Processing 3, PApplet no longer extends Applet (more info here ). In other words, you can't run sketches as an applet anymore.

You'll have to put your main method back in and run it as an application instead.

If you really want to run as an applet, you'll have to create your own class that extends Applet or JApplet , and then add the Processing component to that. That can be pretty convoluted, plus applets are pretty much dead now anyway, so you're probably much better of deploying as an application- or even better, as JavaScript using Processing.js .

As a side note, you shouldn't have to rely on eclipse automatically detecting the run configuration. You should be able to go into the run configurations and create one yourself. That won't work for this specific case, but it's not a bad idea to get more comfortable with the "behind the scenes" stuff so cases like this are less confusing.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM