CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2002
    Location
    Singapore
    Posts
    2

    Exclamation 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()
    {
    .....

    }
    }

  2. #2
    Join Date
    Aug 2002
    Location
    Reykjavik, Iceland
    Posts
    201
    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.

  3. #3
    Join Date
    Dec 2002
    Location
    Singapore
    Posts
    2

    Smile

    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
  •  





Click Here to Expand Forum to Full Width

Featured