Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / March 2007

Tip: Looking for answers? Try searching our database.

JAVA applet probelems

Thread view: 
merrittr - 20 Mar 2007 19:20 GMT
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????
Joshua Cranmer - 20 Mar 2007 22:27 GMT
> 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
[quoted text clipped - 10 lines]
> (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.
merrittr - 21 Mar 2007 07:35 GMT
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>
Andrew Thompson - 21 Mar 2007 13:57 GMT
> 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.
merrittr - 22 Mar 2007 16:24 GMT
yep putting the required libraries worked.

> > not sure I understand the compiled classes are in the same directory
> > as the web page.
[quoted text clipped - 65 lines]
>
> Andrew T.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.