Accessing files in a JAR from an Applet

I've been stuck trying to get my applet to work online. The applet and its inner classes, as well as a folder with a bunch of text files it needs to run, are all in a jar file (on a geocities website =/ just trying to get it working). My html code for the applet looks like this:

<applet code=Graph.class archive="Grapher.jar" height="600" width="1000">

</applet>

Graph is the class that runs the applet, and it has some inner classes for buttons and a drawing pane. When I try to run the applet online, I get this error:

java.lang.NoClassDefFoundError: Graph$MyDrawPanel

at java.lang.Class.getDeclaredConstructors0(Native Method)

at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)

at java.lang.Class.getConstructor0(Unknown Source)

at java.lang.Class.newInstance0(Unknown Source)

at java.lang.Class.newInstance(Unknown Source)

at sun.applet.AppletPanel.createApplet(Unknown Source)

at sun.plugin.AppletViewer.createApplet(Unknown Source)

at sun.applet.AppletPanel.runLoader(Unknown Source)

at sun.applet.AppletPanel.run(Unknown Source)

at java.lang.Thread.run(Unknown Source)

I know that Graph$MyDrawPanel is in the jar, and the applet works in NetBeans, what can i do to make firefox look inside the jar to find my inner classes?

[1350 byte] By [mtb70mpha] at [2007-11-27 10:16:56]
# 1

If you put Graph in a package this should fix the problem

tjacobs01a at 2007-7-28 15:48:32 > top of Java-index,Desktop,Deploying...
# 2

Thanks for the reply!

I put Graph and GetData (the class that gets the data from the text files) in a package called InteractiveGrapher and loaded the whole package into my jar, what should the new applet tag look like? I tried

<applet code=InteractiveGrapher.Graph.class archive="Grapher.jar" height=600 width=1000></applet>

but it doesnt seem to like that, any ideas?

mtb70mpha at 2007-7-28 15:48:32 > top of Java-index,Desktop,Deploying...
# 3

Try this:

<applet code="InteractiveGrapher.Graph.class" codebase="." archive="monarchive.jar" width="1000" heigth="600">

</applet>

See http://java.sun.com/j2se/1.5.0/docs/guide/jar/jarGuide.html

See also the example in the java tutorial

http://java.sun.com/docs/books/tutorial/deployment/applet/browser.html

(See the code source of the web page)

hth,

Message was edited by:

java_2006

java_2006a at 2007-7-28 15:48:32 > top of Java-index,Desktop,Deploying...