Solved

EASY - Applet question

Posted on 2002-03-20
10
192 Views
Last Modified: 2013-11-23
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
0
Comment
Question by:jdc0724
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
10 Comments
 
LVL 35

Accepted Solution

by:
TimYates earned 25 total points
ID: 6882816
Add the ARCHIVE tag to your applet tag:

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

Should work :-)
0
 
LVL 1

Author Comment

by:jdc0724
ID: 6883039
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
0
 
LVL 35

Expert Comment

by:TimYates
ID: 6883151
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.
0
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
LVL 1

Author Comment

by:jdc0724
ID: 6883318
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
0
 
LVL 1

Author Comment

by:jdc0724
ID: 6883327
oops sorry!!  Posted the same message twice.  Please diregard the previous post.
0
 
LVL 35

Expert Comment

by:TimYates
ID: 6883333
Hee hee, ok :-)

Thank-god it's not my eyes going double again... =)
0
 
LVL 1

Author Comment

by:jdc0724
ID: 6883338
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
0
 
LVL 35

Expert Comment

by:TimYates
ID: 6883380
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
0
 
LVL 1

Author Comment

by:jdc0724
ID: 6888877
Very prompt assistance was greatly appreciated.
0
 
LVL 35

Expert Comment

by:TimYates
ID: 6888961
No worries :-)  Glad I could help :-)

Good luck with it!!

Tim.
0

Featured Post

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

615 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question