• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Loading java applet from a cab file failed

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Everyone,
I am trying to load an applet using a cab file. The applet code:
<applet
codebase = "."
code = "Printer.class"
name = "TestApplet"
width = "400"
height = "300"
hspace = "0"
vspace = "0"
align = "middle"
>
<PARAM NAME="cabbase"
VALUE="cabtest.cab">
</applet>

The error that I see in the console:
load: class Printer.class not found.

java.lang.ClassNotFoundException: Printer.class

at sun.applet.AppletClassLoader.findClass(Unknown Source)

at java.lang.ClassLoader.loadClass(Unknown Source)

at sun.applet.AppletClassLoader.loadClass(Unknown Source)

at java.lang.ClassLoader.loadClass(Unknown Source)

at sun.applet.AppletClassLoader.loadCode(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)

Caused by: java.io.FileNotFoundException: C:\cabtest\Printer\class.class (The system cannot find the path specified)

at java.io.FileInputStream.open(Native Method)

at java.io.FileInputStream.<init>(Unknown Source)

at java.io.FileInputStream.<init>(Unknown Source)

at sun.net.www.protocol.file.FileURLConnection.connect(Unknown Source)

at sun.net.www.protocol.file.FileURLConnection.getInputStream(Unknown Source)

at sun.applet.AppletClassLoader.getBytes(Unknown Source)

at sun.applet.AppletClassLoader.access$100(Unknown Source)

at sun.applet.AppletClassLoader$1.run(Unknown Source)

at java.security.AccessController.doPrivileged(Native Method)

All I can see is that its goin wrong in reading the path. But I cant figure out where. I have my cab file in a dir named cabtest and the same directory has the applet's html file.

Please help on this.
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am intrigued by the nested exception:


Caused by: java.io.FileNotFoundException: C:\cabtest\Printer\class.class (The system cannot find the path specified)


since there are no references to class.class in your HTML. Are you attempting to load class.class? The word "class" is a reserved word in Java, so one cannot name a class "class".
 
harmeet bawa
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Joe Ess:
I am intrigued by the nested exception:

since there are no references to class.class in your HTML. Are you attempting to load class.class? The word "class" is a reserved word in Java, so one cannot name a class "class".




I am not tryin to load a file whose name is class.class. My class files name is Printer.class. I am very sure of the issuw being not finding the path. Coz somewhere its not getting set right. But I cant figure out where.
 
Joe Ess
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try changing this parameter

to this:

I have a feeling that the VM thinks you've specified a class "class" in the Printer package, hence the path getting resolved to C:\cabtest\Printer\class.class
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You might also want to leave out the " codebase="." " part. codebase should be an archive, not a directory (and the dot notation is not cross-platform anyway). But Joe's suggestion is likely closer to the mark.
[ July 12, 2005: Message edited by: Ulf Dittmer ]
 
Joe Ess
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ulf Dittmer:
codebase should be an archive, not a directory (and the dot notation is not cross-platform anyway).



CODEBASE is used to indicate a directory.
ARCHIVE is used to indicate an archive.
Have a look at the Java Tutorial on Using the APPLET tag
As for dot, in Windows and *nix a single dot means the current directory. Is there a platform where it does not?
 
harmeet bawa
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ulf Dittmer:
You might also want to leave out the " codebase="." " part. codebase should be an archive, not a directory (and the dot notation is not cross-platform anyway). But Joe's suggestion is likely closer to the mark.

[ July 12, 2005: Message edited by: Ulf Dittmer ]



I did remove the codebase frm there. I thought it might be an issue with using Suns JVM. SO I switched to Microsofts JVM. Well I dont get the class.class not found now. now it cant find the actual class file Printer. Thats what IE says.
 
Joe Ess
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by harmeet bawa:
I thought it might be an issue with using Suns JVM. SO I switched to Microsofts JVM.



There is that. Is there a reason you are using a CAB? Microsoft's VM is stuck at the JDK 1.1.4 API, so it's pretty primitive.
 
harmeet bawa
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well I didnt know abt Microsofts JVM being stuck with jdk 1.1.4. Anyways heres the thing. I already have a jar file which my applet uses. That runs ok. But I had this thought that I can have the applet run a bit faster if I package it as a cab. So I am tryin to test that. Thats why I am tryin to use the cab format. Well heres another question. Does a cab file really reduce the applet loading time as compared to a jar file?
 
harmeet bawa
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well I didnt know abt Microsofts JVM being stuck with jdk 1.1.4. Anyways heres the thing. I already have a jar file which my applet uses. That runs ok. But I had this thought that I can have the applet run a bit faster if I package it as a cab. So I am tryin to test that. Thats why I am tryin to use the cab format. Well heres another question. Does a cab file really reduce the applet loading time as compared to a jar file?
 
Joe Ess
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by harmeet bawa:
Does a cab file really reduce the applet loading time as compared to a jar file?



I've never heard such a thing. Are you comparing applet download speed or applet startup time?
Once upon a time (~1998), JAR files that were used in the classpath could not be compressed. Maybe CAB's could be compressed and that's the reason for a discrepency in applet download speed in the past. Any "modern" VM (i.e. since Java 1.2) handles compressed JAR's, so it's certainly not an issue any more.
Given that MS's VM is ancient and likely doesn't have classes your applet depends on (i.e. Swing, Collections and the like), I'd stick to JAR's and the latest Sun VM.
 
harmeet bawa
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you Joe.
I read an article sayin, if we are using IE, then we can shorten the applet download time using cab files rather than using JAR's. That was the reason I was researching in this direction.
Whatever the thing might be, I am still not able to run my applet with a cab file.
 
Joe Ess
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by harmeet bawa:
I am still not able to run my applet with a cab file.



I tried run an applet in IE myself and I remembered that class files compiled for java 1.5 won't run in MS's ancient VM. You have to tell the compiler to create a class file that will be compatable using the -source and -target directives:

See the javac documentation for more on these options.
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

As for dot, in Windows and *nix a single dot means the current directory. Is there a platform where it does not?



I think Windows is the only non-Unix OS that supports this, so OS 9 and the AS/400 would be examples.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic