Solved

EASY - Applet question

Posted on 2002-03-20
10
183 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
eclipse console opening separately 2 50
passing enum to a method 4 51
DTD and JAVA versions 1 57
Overriding a method 3 13
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Suggested Courses

738 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