java applet stops running on exceptions
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开发者_Python百科 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.
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.
精彩评论