Results 1 to 9 of 9
  1. #1
    Albrecht is offline Member
    Join Date
    Feb 2011
    Posts
    6
    Rep Power
    0

    Default java applet on remote site runs in browser, but fails when opened locally

    There are some nice java applets at the website Receiver Operating Characteristic Curves: an Introduction, and they run fine when I look at the site using firefox.

    But when I download the website files (using wget in linux) and open the same web page as a local html file, the applet fails. I also can't run the roc.class file using the "java" command. Both ways, I get these error messages:

    Java Code:
    Exception in thread "Applet" java.lang.NoClassDefFoundError: ROCGRAPH
    	at java.lang.Class.getDeclaredConstructors0(Native Method)
    	at java.lang.Class.privateGetDeclaredConstructors(Class.java:2406)
    	at java.lang.Class.getConstructor0(Class.java:2716)
    	at java.lang.Class.newInstance0(Class.java:343)
    	at java.lang.Class.newInstance(Class.java:325)
    	at net.sourceforge.jnlp.Launcher.createApplet(Launcher.java:588)
    	at net.sourceforge.jnlp.Launcher.getApplet(Launcher.java:548)
    	at net.sourceforge.jnlp.Launcher$TgThread.run(Launcher.java:729)
    java.lang.NullPointerException
    	at net.sourceforge.jnlp.NetxPanel.runLoader(NetxPanel.java:99)
    	at sun.applet.AppletPanel.run(AppletPanel.java:380)
    	at java.lang.Thread.run(Thread.java:636)
    etc etc.

    I am very confused: how come the applet runs when firefox gets it from the remote server, but not when firefox accesses it as a local file?

    I would deeply appreciate any help.

  2. #2
    NRitH is offline Senior Member
    Join Date
    Feb 2011
    Posts
    118
    Rep Power
    0

    Default

    Because the required jar files are included on the applet's class path in the browser. If you download them and run them locally, you need to make sure to grab the same required jars. View the HTML source of one of their pages and look for the <applet> tag to see what they need.

  3. #3
    Albrecht is offline Member
    Join Date
    Feb 2011
    Posts
    6
    Rep Power
    0

    Default

    Thank you for your helpful suggestion. I looked at the HTML, and it says this:
    Java Code:
    <applet code="roc.class" width="600" height="350">
      <PARAM name="background" value="#F0F0F0">
      <PARAM name="separation" value="50">
      <PARAM name="demarcation" value="33">
      <PARAM name="mode" value="noSeparation,noROC,shading">
      <PARAM name="title" value="Two overlapping normal curves!">
    If you can read this message, then your browser is almost certainly
    not Java enabled. To view the acid-base calculator, get a Java-enabled
    browser!
    </applet>
    So to me it seems that all it mentions is the "roc.class" file. What other file is needed?

  4. #4
    cultclassic is offline Member
    Join Date
    Mar 2011
    Posts
    64
    Rep Power
    0

    Default

    java.lang.NoClassDefFoundError: ROCGRAPH

    means you don't have ROCGRAPH.class

    roc.class is using four other classes, they are not put inside a jar, because they're all in the same directory.

    ROCGRAPH.class
    SIDEPANEL.class
    Watcher.class
    Slider.class
    Last edited by cultclassic; 03-08-2011 at 12:13 AM.

  5. #5
    Albrecht is offline Member
    Join Date
    Feb 2011
    Posts
    6
    Rep Power
    0

    Default

    Quote Originally Posted by cultclassic View Post
    roc.class is using four other classes, they are not put inside a jar, because they're all in the same directory.
    ROCGRAPH.class
    SIDEPANEL.class
    Watcher.class
    Slider.class
    Thank you for your help! I downloaded those files and now in my local copy of the web page the applet works. Could I ask two follow-up questions:
    1) How did you find out that those files were needed? They weren't mentioned in the HTML.
    2) I'd like to be able to run roc.class directly, using my JRE, rather than via the web browser. Should I be able to do this?

    Many thanks

    Albrecht.

  6. #6
    cultclassic is offline Member
    Join Date
    Mar 2011
    Posts
    64
    Rep Power
    0

    Default

    Quote Originally Posted by Albrecht View Post
    1) How did you find out that those files were needed? They weren't mentioned in the HTML.
    By looking at the exceptions thrown on Java console. When I had ROCGRAPH.class, it threw exception for SIDEPANEL.class, and so on...
    I also decompiled roc.class
    Quote Originally Posted by Albrecht View Post
    2) I'd like to be able to run roc.class directly, using my JRE, rather than via the web browser. Should I be able to do this?
    You can use appletviewer. It comes with the Java SDK. I'm not sure if it comes with JRE.
    Last edited by cultclassic; 03-09-2011 at 06:52 PM.

  7. #7
    Albrecht is offline Member
    Join Date
    Feb 2011
    Posts
    6
    Rep Power
    0

    Default

    Quote Originally Posted by cultclassic View Post
    You can use appletviewer. It comes with the Java SDK. I'm not sure if it comes with JRE.
    I managed to get the appletviewer command by installing the java-1.6.0-openjdk-devel package. But it seems not to do anything. I tried it on the original applet in its natural setting
    Java Code:
    appletviewer http://www.anaesthetist.com/mnm/stats/roc/roc.class
    and it just gave a new command prompt, no windows appeared. Does it work for you?

  8. #8
    cultclassic is offline Member
    Join Date
    Mar 2011
    Posts
    64
    Rep Power
    0

    Default

    appletviewer takes the html file as the input. appletviewer needs the applet html tag for things like the size, parameter etc.

  9. #9
    Albrecht is offline Member
    Join Date
    Feb 2011
    Posts
    6
    Rep Power
    0

    Default

    Quote Originally Posted by cultclassic View Post
    appletviewer takes the html file as the input.
    Yes, you're right, it even says so on the man page for appletviewer. I made a stripped-down .html file that just calls the applets, and supplied it as input to appletviewer, and it worked perfectly. Thank you for completely answering my questions.

Similar Threads

  1. Chat applet runs in Eclipse but not on webpage?
    By warydig in forum Java Applets
    Replies: 8
    Last Post: 09-01-2010, 03:54 PM
  2. Replies: 6
    Last Post: 06-07-2010, 03:47 PM
  3. Applet runs on Web page, but no database connection
    By mneskovic in forum Java Applets
    Replies: 4
    Last Post: 05-19-2010, 04:46 AM
  4. Replies: 10
    Last Post: 10-11-2009, 07:07 PM
  5. Replies: 2
    Last Post: 09-12-2008, 06:10 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
  •