简体   繁体   English

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

[英]InvocationTargetException when running an applet from the browser

I have an applet that uses the Processing (http://www.processing.org) library. 我有一个使用处理(http://www.processing.org)库的小程序。 The processing lib is contained in core.jar I'm trying to embed it in a webpage. 处理库包含在core.jar我正在尝试将其嵌入网页中。 Here is the html 这是HTML

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

The applet code is below 小程序代码如下

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....
    }
}

I can post the full applet code but I don't know if it's necessary. 我可以发布完整的applet代码,但我不知道是否有必要。

When I load the .html page. 当我加载.html页面时。 I get a java.lang.reflect.InvocationTargetException. 我得到了一个java.lang.reflect.InvocationTargetException。 There is no stack trace in the Java Console. Java控制台中没有堆栈跟踪。

2 problems: 2个问题:

1) Heart class should be public: 1)心脏课应公开:

   public class Heart extends PApplet { 
      ...

2) Your applet tag should read: 2)您的applet标签应显示为:

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

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

相关问题 从Applet调用Web服务时出现java InvocationTargetException - java InvocationTargetException when calling Web Service from Applet 在浏览器中运行时,Applet无法从MySQL数据库读取数据 - Applet not reading data from MySQL db when running in browser 在浏览器中运行小程序时,ClassNotFound异常 - ClassNotFound Exception when running applet in browser 在浏览器中运行小程序 - Running applet in browser Java Applet未在浏览器中运行 - Java Applet is not running in a browser 在Google App Engine上运行applet时获取InvocationTargetException - getting InvocationTargetException while running an applet on Google App Engine 在junit中运行方法时InvocationTargetException - InvocationTargetException when running a method in junit 运行 javafx 程序时的 InvocationTargetException - InvocationTargetException when running a javafx program Applet在Eclipse中运行良好; 但在Chrome中运行会产生InvocationTargetException - Applet runs fine in Eclipse; but running in Chrome gives InvocationTargetException java.security.AccessControlException:在浏览器上运行小程序时,访问被拒绝 - java.security.AccessControlException: access denied when running applet on browser
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM