views:

59

answers:

1

I have created an applet and made its jar file in Netbeans. i am using a jar file in an applet. I am calling the applet.jar in a jsp page. The applet works fine but the functionality it has to be achieved is through the another jar file which i was using in that applet. means how to include an external jar file in applet.jar so that it could also be available to that jsp page also when i will run the jsp page.

+1  A: 

If you just need to make a jar file available to your applet code, you can just host it from your server and reference it in the <applet> tag. That might be easier than combining the jars, and easier to maintain.

There's a nice overview here, from which I take this example:

<applet code="main.class" codebase="/java" width="100" height="100" archive="applet.zip"> </applet>

...makes the classes in /java/applet.zip available to your application.


Update - the information about the APPLET tag in the Sun/Oracle documentation is comprehensive and easy to follow, i.e. http://download-llnw.oracle.com/javase/1.4.2/docs/guide/misc/applet.html

Brabster
@Barbster..... Here what i am using in index.jsp <applet code="org.me.windowDll.NewJApplet" archive="FindWindowDll.jar,jinvoke.jar" width="600" height="480"/> and jinvoke is in build\web\WEB-INF\lib but still it is not working....
Java_NewBie
Resources in WEB-INF are not available outside the server. You can confirm this by attempting to do a direct fetch on the Jar using the browser's address field. Move them somewhere a normal browser can access them.
Andrew Thompson
@Andrew i tried it but still no use. it cannot find the jinvoke.jar, while it is included in the lib folder
Java_NewBie
1. Please do not paraphrase error messages. Instead copy/paste (http://pscode.org/javafaq.html#exact) error messages. 2. What (bloody) 'lib' folder? A path of '/lib' means the lib directory from the root of the site, but 'lib' means exactly nothing. 3. Is your applet publicly available? I could debug this much faster if I can see it fail in my own browser.
Andrew Thompson
The jar file needs to be accessible from the browser - remember, the applet is running in the browser. /WEB-INF/lib is no good - /WEB-INF and subdirectories are not accessible from outside the web application. To start, try putting your jar file(s) in the same folder as the JSP or HTML file in which the applet is embedded. You should not need to specify a codebase in this case.
Brabster