简体   繁体   English

在Eclipse中运行处理小程序

[英]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. 我已经从其官方网站下载并安装了处理IDE,然后按照说明将库导入eclipse中。 I have core.jar, gluegen-rt.jar and jogl-all.jar added to path. 我将core.jar,glugengen-rt.jar和jogl-all.jar添加到路径中。 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 ). 从处理3开始, PApplet不再扩展Applet此处提供更多信息)。 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. 您必须将main方法放回原处,然后将其作为应用程序运行。

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. 如果您真的想作为applet运行,则必须创建自己的扩展AppletJApplet的类,然后向其中添加Processing组件。 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 . 这可能非常令人费解,而且小程序现在几乎已经死掉了,因此您最好将其部署为应用程序,甚至更好,如使用Processing.js进行 JavaScript部署。

As a side note, you shouldn't have to rely on eclipse automatically detecting the run configuration. 附带说明,您不必依靠eclipse自动检测运行配置。 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. 对于这种特定情况,这是行不通的,但是让自己对“幕后”东西感到更舒服,这不是一个坏主意,因此这样的情况就不会造成混乱。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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