简体   繁体   English

Java Applet停止在异常上运行

[英]java applet stops running on exceptions

I've developed a simple applet that imports an image from the clipboard. 我已经开发了一个简单的applet,可以从剪贴板导入图像。 When i run the class file from NetBeans, everything works fine. 当我从NetBeans运行类文件时,一切正常。 But when i try to run it as an applet ... it gives me lots of errors in the java console and does not run ... - The applet is signed - There is a static method in one class, called getImageFromClipboard(). 但是,当我尝试将其作为applet运行时...它在Java控制台中给我带来很多错误,并且无法运行...-applet已签名-在一个类中有一个静态方法,称为getImageFromClipboard()。 When the applet runs, it calls this method. 小程序运行时,它将调用此方法。 - getImageFromClipboard() method has a try-catch block and suppresses all errors. -getImageFromClipboard()方法具有try-catch块并抑制所有错误。 It simply returns either a BufferedImage or null. 它只是返回BufferedImage或null。 - When applet runs, it does some visual adjustments before calling getImageFromClipboard() Now the scenario is as follows: the class from netbeans runs, fails to import the image and adjusts the interface accordingly (displays an error in a label) But when i run it in a browser, java console is filled with errors and nothing after the getImageFromClipboard() line works. -当applet运行时,它会在调用getImageFromClipboard()之前进行一些视觉上的调整,现在的情况如下:netbeans中的类运行,无法导入图像并相应地调整界面(在标签中显示错误),但是当我运行时在浏览器中,它的Java控制台中充满了错误,但在getImageFromClipboard()行起作用后,它什么也没有。 Although the applet itself loads and does everything it's supposed do do before importing the image. 尽管小程序本身会加载并执行它应该做的所有事情,然后再导入图像。 So why am i getting errors if i accept the certificate and all of the possible errors are in try-catch blocks? 那么,如果我接受证书并且所有可能的错误都在try-catch块中,为什么会出现错误? None of this code should throw any exceptions. 此代码均不应引发任何异常。 Any ideas why this is happening? 任何想法为什么会这样? Or do you need to see the errors to tell? 还是您需要查看错误内容?

UPDATE 更新

I've managed to find out the problem myself. 我设法自己找出问题所在。 The class that i'm using is not in the jar file :( How do i add it in? I'm using "add jar folder" in netbeans on the libraries package to import it but it does not seem to get copied to the jar. 我正在使用的类不在jar文件中:(如何添加它?我在库包上的netbeans中使用“添加jar文件夹”来导入它,但它似乎没有被复制到罐。

I've managed to find out the problem myself. 我设法自己找出问题所在。 The class that i'm using is not in the jar file :( How do i add it in? I'm using "add jar folder" in netbeans on the libraries package to import it but it does not seem to get copied to the jar. 我正在使用的类不在jar文件中:(如何添加它?我在库包上的netbeans中使用“添加jar文件夹”来导入它,但它似乎没有被复制到罐。

You need to specify the dependencies in the archive parameter of the <applet> or <object> tag. 您需要在<applet><object>标记的archive参数中指定依赖项。 You can specify (relative) URL's to those JAR files commaseparated. 您可以为那些以逗号分隔的JAR文件指定(相对)URL。 Here's an example using <object> 's <param> tag: 这是使用<object><param>标记的示例:

<param name="archive" value="file1.jar,file2.jar,file3.jar">

Note that those files are relative to the current request URL (and thus needs to be placed in the same folder as the applet JAR file). 请注意,这些文件是相对于当前请求URL的(因此需要与applet JAR文件放在同一文件夹中)。

If you'd rather like to merge all those JAR's into a single and big JAR file, then you have to look somewhere around in the project properties to Export the buildpath dependency. 如果您想将所有这些JAR合并到一个大的JAR文件中,则必须在项目属性中查找某个地方以导出 buildpath依赖项。 I don't do Netbeans, so I can't tell it in detail, sorry. 我不做Netbeans,所以我不能详细说出来,对不起。

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

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