tags:

views:

40

answers:

1

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.

A: 

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.

BalusC
Balus, thanks for the answer. Basically, i just need a couple of class files from my own class library. So i'd rather import them to the main jar. I don't need a jar in a jar solution or smth. I guess i could manually add these single files to the project, but it would be simpler to have them placed in the jar automatically and only the ones that i really need. I haven't found anything like the buildpath dependency in the settings. I'll try to google that, but i don't seem to find anything useful. I'll just use the html param method if i can't find anything.
Marius
That's exactly what I meant with *Export*. At least, it works that way in Eclipse.
BalusC
Ok the param method works, but i don't want to add a jar, containing all class files. So i've tried the following (i'd automate that later): i need an import of "ms.common.MSImages" so i've created a hierarchy "ms/common/" and added "MSImages.java" in the project's src folder. On build, it creates "ms/common/MSImages.class" in the root of the jar, but then the applet cannot find the class again ... Is that not where this class file should be?
Marius