aspose file tools*
The moose likes Applets and the fly likes extra jar package problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Applets
Bookmark "extra jar package problem" Watch "extra jar package problem" New topic
Author

extra jar package problem

Emil Karlsson
Ranch Hand

Joined: May 23, 2002
Posts: 63
Hi,
I have a couple of extra packages that I import into my applet, but then I run the applet in browser mode it doesn't import it properly (it doesn't seem to find the classes), but when I run it in Appletviewer it works perfectly.
I have placed my extra packages int <java-home>\lib\ext.
Anyone who has any idea what the problems is?
/Emil
Maulin Vasavada
Ranch Hand

Joined: Nov 04, 2001
Posts: 1871
hi Emil
when u include something in <jre>/lib/ext then it would work for the system where you have that code, right? and the AppletViewer runs on that machine. AppletViewer is just one of the local application.
BUT when you see the applet in the browser, the browser runs the applet code after it downloads our application classes used by the applet. Now, here you did put jar files for extra packages in the <jre>/lib/ext so the appletviewer can find it but the browser doesn't know where to download those packages when it downloads the applet.
we have to specify that in our applet's HTML.
we have to use ARCHIVE and CODEBASE attributes to make this happen.
ARCHIVE attribute specifies the name of the jar files which are used by the applet (including the applet if the applet is in the jarfile).
e.g. if you had three jar files,
1. yourAppletJar.jar
2. extraPackage1.jar
3. extraPackage2.jar
then you would write,
ARCHIVE="yourAppletJar.jar, extraPacakge1.jar, extraPackage2.jar" in the <APPLET> tag of the html page you have for the applet.
The CODEBASE specifies that where to download those JAR files. this attribute is required only if we have the applet page's html in some other place and those JARs in different place.
e.g. if you had your applet's html- MyApplet.html in /html directory of your webserver's doc root and the applet's jar, say the above three Jars, in /applet directory then we have to write,
<APPLET CODEBASE="/applet"...
you can search for details on google. just type "APPLET TAG" and see if you find a link that explains in better way than here.
so, basically, you have two solutions to your problem,
1. you need to put those packages in the Jar (if they aren't already) and specify them in ARCHIVE attribute
2. put every package in extracted format in the CODEBASE where the applet is there (the browser convention is that - if it doesn't find the class then it tries to download it from the CODEBASE from where the applet came).
hope i'm little helpful here.
regards
maulin
Emil Karlsson
Ranch Hand

Joined: May 23, 2002
Posts: 63
Thanks a lot Maulin,
I haven't tried it out yet, but it sounds like it is going to work.
Emil
Emil Karlsson
Ranch Hand

Joined: May 23, 2002
Posts: 63
Hi Maulin.
Maybe you can help me/explain what is happening with my applet?
I call my applet from the following html-code

What is happening is when I run it through Appletviewer everything works perfect, but when I try to run it through a browser it won't found some class in knowit_pheedit_save.jar, but the classes from the other two jars is it not any problems to import and instance. I get the following Exception

Is it some problem with signed/unsigned applet or some privacy/properties settings
Thanks in advance.
/Emil
[ May 19, 2003: Message edited by: Emil Karlsson ]
[ May 19, 2003: Message edited by: Emil Karlsson ]
[ May 19, 2003: Message edited by: Emil Karlsson ]
Maulin Vasavada
Ranch Hand

Joined: Nov 04, 2001
Posts: 1871
hi Emil
y u r having APPLET tag and then options that probably works with OBJECT and EMBED tags only.
meaning- we can't probably use the PARAM NAME="something" VALUE="something" format for specification of attributes in APPLET tag. Browser won't know those parameters.
we have to write,
<APPLET ARCHIVE="..." WIDTH="" HEIGHT="" CODE="" CODEBASE=""...>
etc u know....
PARAM tag will only provide parameters to the applet, the browser won't know them. those things works when v r working with OBJECT and EMBED tag...
try that way and let me know if that works for u
regards
maulin
Manoj Pooleery
Ranch Hand

Joined: Sep 20, 2000
Posts: 35
I was searching for an answer to the exact problem. Thanks a lot Maulin. Your answer was really good.
Thanks
-Manoj.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: extra jar package problem