ClassNotFoundException when accessing Processing from Eclipse

ⅰ亾dé卋堺 提交于 2019-12-23 03:04:30

问题


I'm trying to run Processing from Eclipse but whenever I run the application as a Java Application I get java.lang.ClassNotFoundException.

Here's my full code:

import processing.core.PApplet;

public class App extends PApplet {
    public void setup() {
        size(200,200);
        background(0);
    }

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

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


}

Exception:

java.lang.ClassNotFoundException: App
    at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
    at processing.core.PApplet.main(PApplet.java:6522)
    at com.WordClouds.App.main(App.java:17)

回答1:


You are probably doing this tuturial : http://www.learningprocessing.com/tutorials/processing-in-eclipse/

You probably overlooked this :

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

Note that the String “MyProcessingSketch” must match the name of your class (and if it is in a package, should include the package, i.e. packagename.MyProcessingSketch).




回答2:


I had the same problem with the class name correctly set and also the package. This solved my issue:

PApplet.main(new String[] { "--present", MyProcessingSketch.class.getName() }); 


来源:https://stackoverflow.com/questions/21130991/classnotfoundexception-when-accessing-processing-from-eclipse

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!