JAVA applet probelems

M

merrittr

I have a old JDK installed 1.1.8 purposly to compile a applet below:

C:\javapdf\>javac -verbose -classpath C:\jdk1.1.8\lib\classes
SampleReader.java
[parsed SampleReader.java in 194 ms]
[loaded C:\jdk1.1.8\lib\classes\com\adobe\acrobat\Viewer.class in 61
ms]
[loaded C:\jdk1.1.8\lib\classes\com\adobe\acrobat\Viewer
$ViewerTransactor.class
in 21 ms]
[loaded C:\jdk1.1.8\lib\classes\java\applet\Applet.class in 20 ms]
[loaded C:\jdk1.1.8\lib\classes\java\awt\Panel.class in 10 ms]
[loaded C:\jdk1.1.8\lib\classes\java\awt\Container.class in 10 ms]
[loaded C:\jdk1.1.8\lib\classes\java\awt\Component.class in 20 ms]
[loaded C:\jdk1.1.8\lib\classes\java\lang\Object.class in 21 ms]
[checking class SampleReader]
[loaded C:\jdk1.1.8\lib\classes\java\awt\image\ImageObserver.class in
0 ms]
[loaded C:\jdk1.1.8\lib\classes\java\awt\MenuContainer.class in 0 ms]
[loaded C:\jdk1.1.8\lib\classes\java\io\Serializable.class in 0 ms]
[loaded C:\jdk1.1.8\lib\classes\com\adobe\acrobat
\RenderingObserver.class in 0 m
s]
[loaded C:\jdk1.1.8\lib\classes\com\adobe\acrobat\ViewerCommand.class
in 0 ms]
[loaded C:\jdk1.1.8\lib\classes\java\lang\Exception.class in 0 ms]
[loaded C:\jdk1.1.8\lib\classes\java\lang\Throwable.class in 10 ms]
[loaded C:\jdk1.1.8\lib\classes\java\lang\String.class in 30 ms]
[loaded C:\jdk1.1.8\lib\classes\java\awt\Frame.class in 21 ms]
[loaded C:\jdk1.1.8\lib\classes\java\awt\Window.class in 20 ms]
[loaded C:\jdk1.1.8\lib\classes\java\awt\BorderLayout.class in 21 ms]
[loaded C:\jdk1.1.8\lib\classes\java\awt\LayoutManager.class in 0 ms]
[loaded C:\jdk1.1.8\lib\classes\java\awt\LayoutManager2.class in 0 ms]
[loaded C:\jdk1.1.8\lib\classes\java\awt\Label.class in 20 ms]
[loaded C:\jdk1.1.8\lib\classes\java\awt\Color.class in 10 ms]
[loaded C:\jdk1.1.8\lib\classes\java\awt\event\WindowAdapter.class in
0 ms]
[checking class SampleReader. 1]
[loaded C:\jdk1.1.8\lib\classes\java\awt\event\WindowListener.class in
0 ms]
[loaded C:\jdk1.1.8\lib\classes\java\util\EventListener.class in 0 ms]
[loaded C:\jdk1.1.8\lib\classes\java\awt\event\WindowEvent.class in 30
ms]
[loaded C:\jdk1.1.8\lib\classes\java\lang\System.class in 10 ms]
[loaded C:\jdk1.1.8\lib\classes\java\io\FileInputStream.class in 20
ms]
[loaded C:\jdk1.1.8\lib\classes\java\io\InputStream.class in 10 ms]
[loaded C:\jdk1.1.8\lib\classes\java\io\FileDescriptor.class in 0 ms]
[loaded C:\jdk1.1.8\lib\classes\java\io\File.class in 11 ms]
[loaded C:\jdk1.1.8\lib\classes\java\io\FileNotFoundException.class in
10 ms]
[loaded C:\jdk1.1.8\lib\classes\java\io\IOException.class in 0 ms]
[loaded C:\jdk1.1.8\lib\classes\java\io\PrintStream.class in 10 ms]
[loaded C:\jdk1.1.8\lib\classes\java\io\FilterOutputStream.class in 11
ms]
[loaded C:\jdk1.1.8\lib\classes\java\io\OutputStream.class in 10 ms]
[loaded C:\jdk1.1.8\lib\classes\java\lang\Error.class in 0 ms]
[loaded C:\jdk1.1.8\lib\classes\java\lang\RuntimeException.class in 0
ms]
[wrote SampleReader.class]
[wrote SampleReader$1.class]
[done in 1328 ms]

G:\javapdf\>


as you can see it compiles fine
(into 2 classes??? SampleReader.class SampleReader$1.class)


at this point I note that it says in the verbose compile :
[loaded C:\jdk1.1.8\lib\classes\com\adobe\acrobat\Viewer.class in 61
ms]

I then browse to a web page with this applet tag:
<html>
<body>
<applet code="SampleReader.class" width=900 height=140></applet>
</body>
</html>



where I get the following output from the java console:
(which seems to suggest it didn't compile the imported
com/adobe/acrobat/Viewer


Java(TM) Plug-in: Version 1.3.1_19
Using JRE version 1.3.1_19 Java HotSpot(TM) Client VM
User home directory = C:\Documents and Settings\rwm132

----------------------------------------------------
c: clear console window
f: finalize objects on finalization queue
g: garbage collect
h: display this help message
l: dump classloader list
m: print memory usage
q: hide console
s: dump system properties
t: dump thread list
x: clear classloader cache
0-5: set trace level to <n>
----------------------------------------------------

java.lang.NoClassDefFoundError: com/adobe/acrobat/Viewer

at java.lang.ClassLoader.defineClass0(Native Method)

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

at java.security.SecureClassLoader.defineClass(Unknown Source)

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

at sun.plugin.security.PluginClassLoader.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)



any ideas on how I can get this to work????
 
J

Joshua Cranmer

merrittr said:
as you can see it compiles fine
(into 2 classes??? SampleReader.class SampleReader$1.class)

The SampleReader$1.class is an anonymous inner class.
at this point I note that it says in the verbose compile :
[loaded C:\jdk1.1.8\lib\classes\com\adobe\acrobat\Viewer.class in 61
ms]

I then browse to a web page with this applet tag:
<html>
<body>
<applet code="SampleReader.class" width=900 height=140></applet>
</body>
</html>



where I get the following output from the java console:
(which seems to suggest it didn't compile the imported
com/adobe/acrobat/Viewer

It never compiled the code -- the code was already compiled; however,
the applet cannot find the code because it is not located in any class
path. Moving the code to the Java extensions directory (as a JAR file)
or setting a classpath or using custom classloaders would work, the
easiest of which would be to change the classpath.
 
M

merrittr

not sure I understand the compiled classes are in the same directory
as the web page.
To test this I compiles a hello world applet and it worked fine. What
I need to be able to do is make sure
the applet can be downloaded and run by any user


<html>
<body>

<applet code="SampleReader.class" width=900 height=140></applet>
</br>
<applet code="HelloWorld.class" width=900 height=140></applet>
</body>
</html>
 
A

Andrew Thompson

not sure I understand the compiled classes are in the same directory
as the web page.

What compiled classes? Are you saying the 2 (?)
classes your were first mentioning? Or,
'a whole bunch of classes that includes..
com.adobe.acrobat.Viewer.class'?

Viewer class should *not* be in the same
directory as the HTML, but indeed (as a loose
class) a subdirectory of the applet codebase
(in this case, the HTML directory) determined
by the package name.

If the applet is at

http://www.thedomain.com/applet/

Then the Viewer class should be in
http://www.thedomain.com/applet/com/adobe/acrobat/Viewer.class


OTOH, the best thing to do is put it in a jar
archive and include the archive name in
the 'archive' attribute of the applet element.

Lets say the viewer and all the other
classes required, were in a jar called
viewer.jar, which itself was in the same
directory as the applet and web page.

You might change the call like this..
<html>
<body>

<applet code="SampleReader.class"

archive="applet.jar, viewer.jar"
width=900 height=140></applet>
...

This also assumes your two applet classes are
put in archive 'applet.jar' - then the browser
should find all classes.
...What
I need to be able to do is make sure
the applet can be downloaded and run
by any user

Expect a snow storm in Hades, before that
happens. (Or to put that a less obscure way).

You can never *gaurantee* that an end user
will have the correct Java, or any Java,
or that some browser plug-in, browser
manufacturer reaction to a patent challenge,
or any of a dozen other things, causes an
applet to 'not load and run properly'.

As a developer you can take a variety of
measures to help inform an end user that
something has gone wrong, but even in that,
there are no gaurantees.

HTH

Andrew T.
 
M

merrittr

yep putting the required libraries worked.



What compiled classes? Are you saying the 2 (?)
classes your were first mentioning? Or,
'a whole bunch of classes that includes..
com.adobe.acrobat.Viewer.class'?

Viewer class should *not* be in the same
directory as the HTML, but indeed (as a loose
class) a subdirectory of the applet codebase
(in this case, the HTML directory) determined
by the package name.

If the applet is at

http://www.thedomain.com/applet/

Then the Viewer class should be inhttp://www.thedomain.com/applet/com/adobe/acrobat/Viewer.class

OTOH, the best thing to do is put it in a jar
archive and include the archive name in
the 'archive' attribute of the applet element.

Lets say the viewer and all the other
classes required, were in a jar called
viewer.jar, which itself was in the same
directory as the applet and web page.

You might change the call like this..



archive="applet.jar, viewer.jar"


..

This also assumes your two applet classes are
put in archive 'applet.jar' - then the browser
should find all classes.


Expect a snow storm in Hades, before that
happens. (Or to put that a less obscure way).

You can never *gaurantee* that an end user
will have the correct Java, or any Java,
or that some browser plug-in, browser
manufacturer reaction to a patent challenge,
or any of a dozen other things, causes an
applet to 'not load and run properly'.

As a developer you can take a variety of
measures to help inform an end user that
something has gone wrong, but even in that,
there are no gaurantees.

HTH

Andrew T.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top