The Artima Developer Community
Sponsored Link

Java Answers Forum
Problem with packaged applet in HTML page

2 replies on 1 page. Most recent reply: Dec 20, 2004 1:36 PM by Steve Schooler

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 2 replies on 1 page
Steve Schooler

Posts: 17
Nickname: zugzwang
Registered: Aug, 2004

Problem with packaged applet in HTML page Posted: Dec 15, 2004 8:31 PM
Reply to this message Reply
Advertisement

I've been able to run applets from html pages, but
I have trouble when the source code is part of a
package. Assume that :

1. classpath = C:\cpdir
2. code has no package statement.
3. code is compiled in C:\cpdir\subdir
4. raw html (below) is run through an html
converter and then saved into C:\cpdir\subdir
5. jar file created in C:\cpdir\subdir
via jar -cf MyClass.jar *.class
6. then all class files deleted

<APPLET CODE="MyClass.class"
ARCHIVE = MyClass.jar
WIDTH=400 HEIGHT=400> </APPLET>

This works FINE. However, suppose:

1. following statement inserted in MyClass.java

package subdir;

2. compile and creation of jar file work fine
3. raw html (below) run thru converter and saved
into C:\cpdir\subdir

<APPLET CODE="subdir.MyClass.class"
ARCHIVE = MyClass.jar
WIDTH=400 HEIGHT=400> </APPLET>

This FAILS with browser status bar message

MyClass notinited

I tried relocating the (converted) MyClass.html to
C:\cpdir, NO LUCK. How do I get this to work?


Kishori Sharan

Posts: 211
Nickname: kishori
Registered: Feb, 2002

Re: Problem with packaged applet in HTML page Posted: Dec 16, 2004 6:08 PM
Reply to this message Reply
My first guess is that your jar file is not created fine in second case. Note that you have included the package statement in your class in second case. So, when you open your jar file ( you can use winzip to open it) you should see subdir in path column for Myclass.class file.

Just try the following. Instead of creating jar file from c:\cpdir\subdir as
jar file created in C:\cpdir\subdir via jar -cf MyClass.jar *.class

create it as:

jar file created in C:\cpdir via jar -cf MyClass.jar subdir\*.class

This will place MyClass.class file under subdir path, so MyClass full-qualified name will be subdir.MyClass.

Thanks
Kishori

Steve Schooler

Posts: 17
Nickname: zugzwang
Registered: Aug, 2004

Re: Problem with packaged applet in HTML page Posted: Dec 20, 2004 1:36 PM
Reply to this message Reply
Right on target, thanks for the insight. Your remedy worked.

Flat View: This topic has 2 replies on 1 page
Topic: reference equals null Previous Topic   Next Topic Topic: Problem with dropdown

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use