Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jar file

 
Garandi Garandi
Ranch Hand
Posts: 192
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I build a jar file called "A.jar", to invoke my applet from.
In one of ".class" file, I have imported a class which is in a jar file say "B.jar", if I include B.jar in A.jar the class which uses the class which is in B.jar throws an exception cannot find the class.
I am new to applet any help is welcome.
Thank you
Garandi
 
Karan V Praba
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hai,
U need to give Class-Path:B.jar in manifest file of A.jar. And try it out.Location of B.jar is relative path of A.jar.
 
Karan V Praba
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't add B.jar into A.jar.
 
Avi Abrami
Ranch Hand
Posts: 1141
1
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Garandi,
Although you can nest JAR files (i.e. package one JAR file inside another), java doesn't know how to handle nested JAR files (as you have seen ;-)
In order to overcome your problem, you have several options -- one of which has already been mentioned by Karan (namely, using the "Class-Path:" header of the JAR manifest file).
Another option would be to build a new JAR file that contains all the classes from "A.jar" and "B.jar" (if that's feasible for you).
Note that the <APPLET> tag has an ARCHIVE attribute that can take a list of JAR files. Here is a quote from the relevant javadoc:
http://java.sun.com/j2se/1.4.1/docs/guide/misc/applet.html

ARCHIVE = archiveList
This OPTIONAL attribute describes one or more archives containing classes and other resources that will be "preloaded". The classes are loaded using an instance of an AppletClassLoader with the given CODEBASE.
The archives in archiveList are separated by ",".

So you could list both "A.jar" and "B.jar" in your archive list.
Hope this has helped you.
Good Luck,
Avi.
 
Garandi Garandi
Ranch Hand
Posts: 192
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Karan and Avi thanks for reply.
Garandi
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic