Results 1 to 1 of 1
  1. #1
    mzatanoskas is offline Member
    Join Date
    Feb 2009
    Posts
    5
    Rep Power
    0

    Default Cannot run Java from Firefox Extension using liveconnect?!

    Hi, I'm trying to run a very simple java program from a Firefox extension I'm making but I've run into a brickwall and just can't get it to work. I'm a complete beginner in java and don't know much javascript so I've copied and pasted code from around the net to get where I am now. I'm sure I'm just making some stupid error at some step.

    In order to work out what I'm misunderstanding/doing wrong I'd be really grateful if someone could show me how to get it to work using a very basic example:

    Say I have a .java file taken from the sun pages:
    Java Code:
    /** 
     * The HelloWorldApp class implements an application that
     * simply displays "Hello World!" to the standard output.
     */
    class HelloWorldApp {
        public static void main(String[] args) {
            System.out.println("Hello World!"); //Display the string.
        }
    }
    So I stick it into a jar using:

    jar.exe cvfe HelloWorldApp.jar HelloWorldApp.class HelloWorldApp.class

    I then place it directly on my C: drive.

    In the javascript of my firefox extension I have code copied and pasted from developer.mozilla.org/en/Java_in_Firefox_Extensions:

    Java Code:
    var urlClasz = java.lang.Class.forName("java.net.URL");
    var urlArray = java.lang.reflect.Array.newInstance(urlClasz,1);
    urlArray[0] = new java.net.URL('file:///C:/HelloWorldApp.jar');
    var cl = java.net.URLClassLoader.newInstance(urlArray);
    var aClass = java.lang.Class.forName("HelloWorldApp", true, cl);
    var aStaticMethod = aClass.getMethod("HelloWorldApp", []);
    var greeting = aStaticMethod.invoke(null, []);
    This seems to start java but then only gives me the error:

    "Error: uncaught exception: Error calling method on NPObject! [plugin exception: java.lang.ClassNotFoundException: HelloWorldApp]."

    I would be infinitely grateful if someone could show me the code I would use in this situation to run the HelloWorldApp. If I could get it working in this basic situation I'm sure I could work it out from there.

    Thank you very, very much!!
    Last edited by mzatanoskas; 02-13-2009 at 10:20 AM.

Similar Threads

  1. Replies: 0
    Last Post: 11-24-2008, 07:48 PM
  2. Issue jsp with FireFox
    By dimuthunsj in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 10-10-2008, 12:08 PM
  3. Replies: 0
    Last Post: 08-26-2008, 10:00 PM
  4. Getting domainname/user in Firefox
    By Ganesh Prasad in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 02-14-2008, 02:13 PM
  5. IE and Firefox
    By Ed in forum Advanced Java
    Replies: 1
    Last Post: 06-15-2007, 05:16 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •