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 2005

Tip: Looking for answers? Try searching our database.

Using Applets in JavaScript

Thread view: 
mexicanopelon - 04 Mar 2005 14:33 GMT
Greetings,

Although I am familiar with JavaScript, I am new to the concept of
using Applets in JS.  Here is what I am trying to do.  I have an Applet

will call "FooApplet" with some "fooFunction" returning a String.  The
applet accesses a class "ExternalClass" with some "externalFunc"
returning a String.  "ExternalClass" is part of a .jar file will call
"externals.jar".

public class FooApplet extends Applet {

   public String fooFunction(String input1, String input2) {
      do some stuff....
      ExternalClass ec = new ExternalClass();
      return (ec.externalFunc(param1, param2);
   }

}

In my JavaScript file I am calling the "fooFunction" as follows:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
 <TITLE></TITLE>

<SCRIPT LANGUAGE="JavaScript">
<!--
function doSomething() {
 alert(document.fooApp.fooFunction("input1", "input2");

}

// -->
</SCRIPT>
</HEAD>

<BODY BGCOLOR="WHITE">
<H1>Queue Depth</H1>

<APPLET CODE="FooApplet" ARCHIVE="externals.jar" WIDTH=10 HEIGHT=10
NAME="fooApp">
</APPLET>

Click the link to see something:
 <A onClick="doSomething()"> Do Something </A>

</BODY>
</HTML>

The Java code compiles fine.  When I open the HTML page it shows up
fine and the status bar indicates that the Applet has started.  When I
click on the link I get a "java.lang.NoClassDefFoundError".  I have
determined that problem is linked to the Applet trying to access the
function in the "ExternalClass", because it works when I replace
'return (ec.externalFunc(param1, param2)' with a simple 'return
("Hello");'.  As you can see I even tried adding the external .jar file

to the ARCHIVE attribute, but it still doesn't work.

If you have any suggestions, please let me know?  

Thanks.
William Brogden - 04 Mar 2005 15:24 GMT
> Greetings,
>
[quoted text clipped - 5 lines]
> returning a String.  "ExternalClass" is part of a .jar file will call
> "externals.jar".

IF your applet and external class are not presently in a package,
the first thing I would try is putting both in a package. Finding
classes not in a package is chancy.

> public class FooApplet extends Applet {
>
[quoted text clipped - 50 lines]
>
> Thanks.

Signature

Using Opera's revolutionary e-mail client: http://www.opera.com/m2/

mexicanopelon - 04 Mar 2005 15:59 GMT
Hi William,

Thanks for the reply.  My external package is definitely in a package,
my applet is not.  Do you think it will help if I add it to a package?
Will it matter if they are not part of the same package?

Thanks,

Carlos
William Brogden - 05 Mar 2005 13:41 GMT
> Hi William,
>
> Thanks for the reply.  My external package is definitely in a package,
> my applet is not.  Do you think it will help if I add it to a package?

Like I said - that is what I would try - I always try the simplest
fixes first : )

> Will it matter if they are not part of the same package?

That should not matter.


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.