File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Applets and the fly likes Loading java applet from a cab file failed Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Applets
Bookmark "Loading java applet from a cab file failed" Watch "Loading java applet from a cab file failed" New topic
Author

Loading java applet from a cab file failed

harmeet bawa
Greenhorn

Joined: Sep 12, 2004
Posts: 22
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.
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8908
    
    8

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".


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
harmeet bawa
Greenhorn

Joined: Sep 12, 2004
Posts: 22
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

Joined: Oct 29, 2001
Posts: 8908
    
    8

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
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41867
    
  63
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 ]

Ping & DNS - my free Android networking tools app
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8908
    
    8

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

Joined: Sep 12, 2004
Posts: 22
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

Joined: Oct 29, 2001
Posts: 8908
    
    8

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

Joined: Sep 12, 2004
Posts: 22
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

Joined: Sep 12, 2004
Posts: 22
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

Joined: Oct 29, 2001
Posts: 8908
    
    8

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

Joined: Sep 12, 2004
Posts: 22
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

Joined: Oct 29, 2001
Posts: 8908
    
    8

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
Marshal

Joined: Mar 22, 2005
Posts: 41867
    
  63
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Loading java applet from a cab file failed