java 小程序因异常而停止运行

发布于 2024-08-27 06:37:59 字数 659 浏览 4 评论 0原文

我开发了一个简单的小程序,可以从剪贴板导入图像。当我从 NetBeans 运行类文件时,一切正常。但是当我尝试将它作为小程序运行时...它在java控制台中给了我很多错误并且不运行... - 小程序已签名 - 一个类中有一个静态方法,称为 getImageFromClipboard()。当小程序运行时,它会调用此方法。 - getImageFromClipboard() 方法有一个 try-catch 块并抑制所有错误。它只是返回 BufferedImage 或 null。 - 当小程序运行时,它会在调用 getImageFromClipboard() 之前进行一些视觉调整 现在的场景如下:netbeans 中的类运行,无法导入图像并相应地调整界面(在标签中显示错误) 但是当我在浏览器中运行它时,java 控制台充满了错误,并且 getImageFromClipboard() 行之后没有任何内容。尽管小程序本身会加载并执行导入图像之前应该执行的所有操作。 那么,如果我接受证书并且所有可能的错误都在 try-catch 块中,为什么我会收到错误呢?此代码不应引发任何异常。 有什么想法为什么会发生这种情况吗?或者您需要查看错误才能判断吗?

更新

我自己已经设法找出问题所在。我正在使用的类不在 jar 文件中:( 我如何添加它?我在库包上的 netbeans 中使用“添加 jar 文件夹”来导入它,但它似乎没有被复制到罐。

I've developed a simple applet that imports an image from the clipboard. When i run the class file from NetBeans, everything works fine. 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(). When the applet runs, it calls this method.
- getImageFromClipboard() method has a try-catch block and suppresses all errors. It simply returns either a BufferedImage or 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. 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? 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

舞袖。长 2024-09-03 06:37:59

我自己已经设法找出问题所在。我正在使用的类不在 jar 文件中:( 我如何添加它?我在库包上的 netbeans 中使用“添加 jar 文件夹”来导入它,但它似乎没有被复制到罐子。

您需要在 标记的 archive 参数中指定依赖项 您可以为这些 JAR 文件指定(相对)URL,以逗号分隔。下面是使用 标记的示例:

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

请注意,这些文件是相对于当前请求 URL(因此需要放置在与小程序 JAR 文件相同的文件夹中)。

如果您希望将所有这些 JAR 合并到一个大的 JAR 文件中,那么您必须在项目属性导出构建路径依赖项我不使用Netbeans,所以我无法详细说明,抱歉。

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.

You need to specify the dependencies in the archive parameter of the <applet> or <object> tag. You can specify (relative) URL's to those JAR files commaseparated. Here's an example using <object>'s <param> tag:

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

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. I don't do Netbeans, so I can't tell it in detail, sorry.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文