|
-
December 4th, 2002, 03:00 AM
#1
calling java from javascript
hi!
I like to call a java file from javascript but run into error indicating unresolved class name. For a classname rd, the error states "rd is null or not a valid class". Can anyone give an idea on how to solve this? Below is my html codes & java sample file. Had been trying for many days but to no avail.
<html>
<head>
<title>Welcome!</title>
<SCRIPT LANGUAGE="JavaScript">
function read()
{
document.rd.reading();
}
</SCRIPT>
</head>
Please click here to begin
<br>
<FORM >
<INPUT TYPE=SUBMIT value="Start!" onClick="read()">
<SCRIPT LANGUAGE="JavaScript">
for(i=0;i<10;i++)
{
document.writeln( "<BR>" + rd.score[i]);
}
</SCRIPT>
</center>
</body>
</html>
import java.io.*;
public class rd
{
public static int MAX = 10;
public static byte[] score = new byte[MAX];
public void reading()
{
.....
}
}
-
December 4th, 2002, 03:16 PM
#2
I'm assuming that the Java file is for a Java applet that is embedded into the document?
If so, then use the DOM to reference the applet and with Liveconnect you can call a method of the applet:
document.applets[0].reading();
Note that you do not need to reference the class, just the method used in that applet.
-
December 4th, 2002, 09:08 PM
#3
is it possible to just call a method in the .class java instead of using applet? the .class java program is to read data from a file at client-side into an array (known as score[]) before sending this array content onto a server. Thus i would like to hide this processing from the html page. Please advice on this. thanks!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|