Link to home
Start Free TrialLog in
Avatar of jdc0724
jdc0724

asked on

EASY - Applet question

I have an applet that uses classes from a jar file "COS.JAR".   Problem is, that unless I run the applet on my own pc, it cannot find the classes contained in the JAR file.  I have read documentation that explains the process of running an applet that is "contained" in a jar file but have found nothing about applets that are "not" contained in a jar, BUT import classes that ARE in a jar.  

I would like to know how I can get the applet to work correctly with importing classes that are in a JAR file, when the applet is not in the jar itself?

Thanks,
JDC
ASKER CERTIFIED SOLUTION
Avatar of TimYates
TimYates
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jdc0724
jdc0724

ASKER

Are you suggesting that I put the applet in a jar by itself and then include the paths to the applet JAR and the COS.jar in the archive tag??  Is there any benefit to having the applet in its own jar or can I just specify the COS.jar in the archive tag and not bundle the applet?

Thanks,
JDC
Yup, that should work too :-)

<APPLET
 CODEBASE = "."
 CODE     = "Main.class"
 ARCHIVE  = "COS.jar"
 NAME     = "MainApplet"
 WIDTH    = 800
 HEIGHT   = 600
>
</APPLET>

So long as the COS jar is in the same directory as your applet class =)

Good luck!!

Hope it works!!

Tim.
Avatar of jdc0724

ASKER

Are you suggesting that I put the applet in a jar by itself and then include the paths to the applet JAR and the COS.jar in the archive tag??  Is there any benefit to having the applet in its own jar or can I just specify the COS.jar in the archive tag and not bundle the applet?

Thanks,
JDC
Avatar of jdc0724

ASKER

oops sorry!!  Posted the same message twice.  Please diregard the previous post.
Hee hee, ok :-)

Thank-god it's not my eyes going double again... =)
Avatar of jdc0724

ASKER

Currently I have the COS.jar file in my Tomcat/lib directory so the COS.jar file is known serverwide (obviously this dosen't apply to applets).  But can I specify absolute paths in the "archive" tag or does it have to be in the same directory always?  Since the COS.jar file is in the Tomcat/lib directory and included in the classpath, is there an easier way to refer to the jar in the archive tag?

Thanks,
JDC
I am not sure, but I don't think so

The browser is the thing that downloads the Jar, and so it has to be accessible from web-browsers

Therefore, the jar file has to be in the webapps directory somewhere

The classpath for tomcat on the server will have no effect, as the applet is running on the client machine

I am not sure if you can set up a lib directory inside webapps, and then reference the jar with

  ARCHIVE= "/lib/COS.jar"

This MIGHT work (but I doubt it)

Hmmm...I always have it all over the place (as I am a sloppy kinda guy)

Let me know if you find a neater solution...I will be interested =)

Tim
Avatar of jdc0724

ASKER

Very prompt assistance was greatly appreciated.
No worries :-)  Glad I could help :-)

Good luck with it!!

Tim.