Solved

EASY - Applet question

Posted on 2002-03-20
10
162 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
  • 5
  • 5
10 Comments
 
LVL 35

Accepted Solution

by:
TimYates earned 25 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 1

Author Comment

by:jdc0724
Comment Utility
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
Comment Utility
oops sorry!!  Posted the same message twice.  Please diregard the previous post.
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 35

Expert Comment

by:TimYates
Comment Utility
Hee hee, ok :-)

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

Author Comment

by:jdc0724
Comment Utility
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
Comment Utility
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
Comment Utility
Very prompt assistance was greatly appreciated.
0
 
LVL 35

Expert Comment

by:TimYates
Comment Utility
No worries :-)  Glad I could help :-)

Good luck with it!!

Tim.
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
triangle challenge 4 75
countX 22 68
get weblogic logged in user in java 2 39
Java / Linux and Regular Expressions 11 43
For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

771 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now