Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

EASY - Applet question

Posted on 2002-03-20
10
Medium Priority
?
201 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 100 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Suggested Courses

963 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