Newsgroup: it.comp.java
Titolo: JAR and APPLETS

I'm trying to gather all my applet files into a .jar archive.
While all runs fine with the normal .class files, the browser doesn't find
any class if
I use the archive.
This is the HTML declaration of my applet:
<applet code=Quakelet.class archive=Quake.jar
        width=600 height=300>
<PARAM NAME="eqlistfile" VALUE="eqList.act">
</applet>
I've put this html file in the same directory of Quake.jar file. I've also
tryed with
archive="Quake.jar" and archive="C:\\...\\Quake.jar" and
"/.../Java/JQuake/Quake.jar"
and some other odd combination. Results: anyone.
This is the list of the files inside "Quake.jar" as the result of "jar tf
Quake.jar"
META-INF/
META-INF/MANIFEST.MF
itemListener.class
psn/
psn/PSNArchive.class
psn/PSNException.class
psn/PSNReader.class
psn/DeCompl.class
psn/PSNSummary.class
psn/SummaryShow.class
psn/PSNHeader.class
psn/PSNCoord.class
psn/PSN1stHdr.class
psn/PSN2ndHdr.class
psn/PSN2ndHdrOld.class
psn/PSN2ndHdrNew.class
QuakeCanvas.class
Quakelet.class
QuakeRdList.class
QuakeServer/
QuakeServer/QuakeServer.cfg
QuakeServer/PSNFilter.class
QuakeServer/QuakeServer.class
All files contained in QuakeServer folder are not important for the applet.
This is what appears in the Java-Console window of Internet Explorer:
java.io.FileNotFoundException: \C:\MicWorks\Java\JQuake\Quakelet.class
java.lang.ClassNotFoundException: Quakelet
at com/ms/vm/loader/URLClassLoader.loadClass
at com/ms/vm/loader/URLClassLoader.loadClass
at com/ms/applet/AppletPanel.processSentEvent
at com/ms/applet/AppletPanel.processSentEvent
at com/ms/applet/AppletPanel.run
at java/lang/Thread.run
Look at the first row: why JVM tried to open the file searching in that
strange
absolute path? I'm sure I didn't put any absolute path in any place, neither
in the code
nor in the .html.
And why the first character is a \ ? Of course this can't run on a Windows
system:
\C:\MicWorks\Java\JQuake\Quakelet.class is not a valid file path due to the
"\".
This problem is driving me crazy.
Thanks in advance for the help
   Michele Rossi (my return address is VALID)

Can you get the browser to read other applets using jar files?
Michele wrote:

--
Lars Roe
612-625-7797
roex...@tc.umn.edu

In all of the the book and tutorial examples I have seen, the authors name the
jar file the same as the class they are calling. For example:
(from 
http://www.javasoft.com/docs/books/tutorial/jar/basics/run.html
)
"As an example, let's use (again!) the TicTacToe demo applet that ships with the
JavaTM
          Development Kit. The APPLET tag in the HTML file that calls the demo
looks like this:
               <applet code=TicTacToe.class
                       width=120 height=120>
               </applet>
          If the TicTacToe demo were packaged in a JAR file named TicTacToe.jar,
you could modify the
          APPLET tag with the simple addition of an ARCHIVE parameter:
               <applet code=TicTacToe.class
                       archive="TicTacToe.jar"
                       width=120 height=120>
               </applet>
          The ARCHIVE parameter specifies the relative path to the JAR file that
contains
          TicTacToe.class. This example assumes that the JAR file and the HTML
file are in the same
          directory. If they're not, you would need to include the JAR file's
relative path in the ARCHIVE
          parameter's value. For example, if the JAR file was one directory
below the HTML file in a directory
          called applets, the APPLET tag would look like this:
               <applet code=TicTacToe.class
                       archive="applets/TicTacToe.jar"
                       width=120 height=120>
               </applet>"
Is this a requirement of the language? I don't know; I never find it explicitly
stated. If the system is looking for "Quakelet.jar" would it spit out the
strange results you're getting? What if you tried renaming the jar file to
Quakelet.jar? Hope this helps.


I call my jar files and applet files different and it works fine.
Chris Hall wrote:

--
Lars Roe
612-625-7797
roex...@tc.umn.edu

 </applet>
Isn't the parameter ARCHIVES = Quake.jar?
/jonas

 Is this a requirement of the language? 
Emphatically not. Think of jarfile name as similar to directory
name; as long as the jarfile appears on the classpath, its name
doesn't really affect anything. Look at the standard JDK examples;
most of them use ExampleApplet.jar no matter what classes they
contain.
(Pedagogical examples often have unnecessary and unreasonable
constraints, simply because the authors don't want to take time
to explain why they made the choices they did. Don't take
sample code as gospel.)
-----------------------------------------------------------------
Joe Kesselman ("Keshlam"), 
http://www.lovesong.com/people/keshlam
     New URL for Walkabout Clearwater Coffeehouse and Chorus:
 
http://www.lovesong.com/walkabout

With a .zip file all works fine!
Anyway thanks a lot for your replies and sorry of my delay in checking them
  Michele