繁体   English   中英

从浏览器运行小程序时,InvocationTargetException

[英]InvocationTargetException when running an applet from the browser

我有一个使用处理(http://www.processing.org)库的小程序。 处理库包含在core.jar我正在尝试将其嵌入网页中。 这是HTML

<html>    
<body>
<applet width=300 height=300 code="Applet.class" archive="core.jar"> 
   no applet
</applet>
</body>    
</html>

小程序代码如下

import processing.core.*;
import java.util.ArrayList;


class Heart extends PApplet //subclass of Applet
{
    Particle p;
    ArrayList<Particle> particles;
    PImage heart;


    public void setup() //These are overrides of PApplet methods
    {
        ...do stuff...
    }

    public void draw() //These are overrides of PApplet methods
    {
        ...more stuff....
    }

    PVector randVec(float min, float max)
    {
      ...etc etc....
    }
}

我可以发布完整的applet代码,但我不知道是否有必要。

当我加载.html页面时。 我得到了一个java.lang.reflect.InvocationTargetException。 Java控制台中没有堆栈跟踪。

2个问题:

1)心脏课应公开:

   public class Heart extends PApplet { 
      ...

2)您的applet标签应显示为:

<applet width=300 height=300 code="Heart.class" archive="core.jar"> 

暂无
暂无

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

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