Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / January 2006

Tip: Looking for answers? Try searching our database.

Applets and Deep Jar Structure

Thread view: 
spifster - 06 Jan 2006 14:49 GMT
---------------------------------QUESTION-----------------------------------
I have been trying to run an applet by using a file nestled deep within
the directory structure of a jar.  The html file containing the applet
tag, and the jar file exist in the same folder.  However the jar has
the following structure /bah/xroads/graphing/JSciGraph.class.  Does
anyone know the syntax for solving this problem.

---------------------------------REFERENCES-----------------------------------

Special syntax for referencing the structure of a jar can be found at:

http://mindprod.com/jgloss/jar.html

JDK 1.2+ has many new classes for handling jars.
java.net.JarURLConnection lets you access a remote jar just as if it
were a remote sequential file by using a new URL syntax:
jar:http://www.foo.com/bar/baz.jar!/COM/foo/Quux.class. The !/
separates the member name from the filename. java.util.jar.JarFile lets
you randomly process local jar files. java.net.URLClassLoader lets you
load classes from arbitrary jar sources, not just the archive jars.

I've also found an object tag that has been used for something similar
at:

http://msdn.microsoft.com/workshop/author/dhtml/reference/properties/codebase.asp

with the following syntax:

<OBJECT ID="CommonDialog1" WIDTH=32 HEIGHT=32
   CLASSID="CLSID:F9043C85-F6F2-101A-A3C9-08002B2F49FB"
   CODEBASE="http://activex.microsoft.com/controls/vb5/comdlg32.cab
   #Version=1,0,0,0">
</OBJECT>
---------------------------------SOURCE-----------------------------------
Some recent of accessing the file include:

<HTML>
<APPLET CODE="JSciGraph.class"
    ARCHIVE="ohta.jar!/bah/xroads/graphing/"
    WIDTH=100
    HEIGHT=100>
</APPLET>
</HTML>

 and

<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
WIDTH = 500 HEIGHT = 500  >
<PARAM NAME = CODE VALUE = bah.xroads.graphing.JSciGraph >
<PARAM NAME = ARCHIVE VALUE = ohta.jar >
<PARAM NAME="type" VALUE="application/x-java-applet;version=1.2">

</OBJECT>

-------------------------------------------------------------------
Thanks in advance,

David C. Garay
Andrew Thompson - 07 Jan 2006 08:42 GMT
> ---------------------------------QUESTION-----------------------------------
> I have been trying to run an applet by using a file nestled deep within
> the directory structure of a jar.  The html file containing the applet
> tag, and the jar file exist in the same folder.  However the jar has
> the following structure /bah/xroads/graphing/JSciGraph.class.  Does
> anyone know the syntax for solving this problem.
..
> ---------------------------------SOURCE-----------------------------------
> Some recent of accessing the file include:
>
> <HTML>
> <APPLET CODE="JSciGraph.class"

What is the *package* of this class? ..

>      ARCHIVE="ohta.jar!/bah/xroads/graphing/"

If it is..
bah.xroads.graphing(.JSciGraph), you need something like..

  code='bah.xroads.graphing.JSciGraph'
  archive='ohta.jar'

HTH

Signature

Andrew Thompson
physci, javasaver, 1point1c, lensescapes - athompson.info/andrew

Roedy Green - 07 Jan 2006 19:53 GMT
>I have been trying to run an applet by using a file nestled deep within
>the directory structure of a jar.  The html file containing the applet
>tag, and the jar file exist in the same folder.  However the jar has
>the following structure /bah/xroads/graphing/JSciGraph.class.  Does
>anyone know the syntax for solving this problem.

What do you want to do with the class file once you find it?  If you
want to load it just access one of the methods of
bah.xroads.graphing.JSciGraph.

If you want to read its bytes :

this.getClass().getResourceAsStream( "JSciGraph.class" )
where this is a class in that package.

If this is not of that package use

this.getClass().getResourceAsStream(
"/bah/xroads/graphing/JSciGraph.class" )
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.