10 Replies Latest reply on Sep 22, 2011 1:41 AM by 889476

    Class not found in applet using 2 jar files

    889476
      I have an applet which has been working for years as a stand alone or connecting directly to a derby database on my home server. I have just changed it to connect to MySQL on my ISP server via AJAX and PHP.

      I am now getting a class not found error in my browser, probably because I'm stuffing up the class path.

      The HTML I am using to call the applet is:
      <applet code="AMJApp.class" 
      codebase="http://www.interactived.com/JMTalpha" 
      archive="AMJ014.jar,plugin.jar" 
      width="500"height="500" 
      MAYSCRIPT style="border-width:0;" 
      name="jsap" id="jsap"></applet>
      The AMJ014.jar contains the applet and supporting class files.

      The error message is strange to me because it refers to a class I noticed on another web page but which has nothing to do with my applet. Anyway, the message in full is:
      load: class NervousText.class not found.
      java.lang.ClassNotFoundException: NervousText.class
           at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
           at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source)
           at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
           at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
           at java.lang.ClassLoader.loadClass(Unknown Source)
           at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source)
           at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
           at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
           at java.lang.Thread.run(Unknown Source)
      Exception: java.lang.ClassNotFoundException: NervousText.class
      java.lang.UnsupportedClassVersionError: AMJApp : Unsupported major.minor version 51.0
           at java.lang.ClassLoader.defineClass1(Native Method)
           at java.lang.ClassLoader.defineClassCond(Unknown Source)
           at java.lang.ClassLoader.defineClass(Unknown Source)
           at java.security.SecureClassLoader.defineClass(Unknown Source)
           at java.net.URLClassLoader.defineClass(Unknown Source)
           at java.net.URLClassLoader.defineClass(Unknown Source)
           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
           at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
           at java.lang.reflect.Method.invoke(Unknown Source)
           at sun.plugin2.applet.Plugin2ClassLoader.defineClassHelper(Unknown Source)
           at sun.plugin2.applet.Plugin2ClassLoader.access$100(Unknown Source)
           at sun.plugin2.applet.Plugin2ClassLoader$2.run(Unknown Source)
           at java.security.AccessController.doPrivileged(Native Method)
           at sun.plugin2.applet.Plugin2ClassLoader.findClassHelper(Unknown Source)
           at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
           at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source)
           at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
           at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
           at java.lang.ClassLoader.loadClass(Unknown Source)
           at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source)
           at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
           at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
           at java.lang.Thread.run(Unknown Source)
      Exception: java.lang.UnsupportedClassVersionError: AMJApp : Unsupported major.minor version 51.0
        • 1. Re: Class not found in applet using 2 jar files
          793415
          Unsupported major.minor version 51.0
          The code is being compiled by a Java 7 SDK (without cross-compilation options), but the user is trying to run it on a version 6 or lower JRE.
          1 person found this helpful
          • 2. Re: Class not found in applet using 2 jar files
            889476
            Many thanks for your reply. I wondered what that meant.

            However, this is the error generated by JRE 1.7:
            Java Plug-in 10.0.0.147
            Using JRE version 1.7.0-b147 Java HotSpot(TM) Client VM
            User home directory = C:\Users\MJHIPP
            ----------------------------------------------------
            c:   clear console window
            f:   finalize objects on finalization queue
            g:   garbage collect
            h:   display this help message
            l:   dump classloader list
            m:   print memory usage
            o:   trigger logging
            q:   hide console
            r:   reload policy configuration
            s:   dump system and deployment properties
            t:   dump thread list
            v:   dump thread stack
            x:   clear classloader cache
            0-5: set trace level to <n>
            ----------------------------------------------------
            Detected from bootclasspath: C:\\PROGRA~1\\Java\\jre7\\lib\\deploy.jar
            starting... 
            • 3. Re: Class not found in applet using 2 jar files
              793415
              886473 wrote:
              Many thanks for your reply. I wondered what that meant.
              It took me less than 2 minutes of searching to discover the reason.
              However, this is the error generated by JRE 1.7:
              Java Plug-in 10.0.0.147
              Using JRE version 1.7.0-b147 Java HotSpot(TM) Client VM
              User home directory = C:\Users\MJHIPP
              ----------------------------------------------------
              c:   clear console window
              ...
              Huh, that's odd. BTW:

              <ol>
              <li>Why does the applet add the (Oracle - JRE) <tt>plugin.jar</tt> to the run-time class-path of the applet? Remove it. It is automatically on the class-path of embedded applets (perhaps only if <tt>MAYSCRIPT</tt> is declared, I'm a bit hazy on the details).
              <li>What is the entire HTML of the page in question? (I'd prefer the entire HTML of a page that is the minimum needed to reproduce the problem.)
              <li>Do you have a link where we can see the applet? Or can you reproduce the problem at a link we can visit?
              </ol>
              • 4. Re: Class not found in applet using 2 jar files
                889476
                Thanks again.

                The page code is:
                <html>
                <head>
                  <title>Applet to JavaScript to PHP</title>
                </head>
                <body>
                <script type="text/javascript">
                function updateWebPage(myArg)
                {
                document.getElementById("txt1").innerHTML=myArg;
                if (myArg=="")
                  {
                  document.getElementById("cbxItem").innerHTML="";
                  return;
                  }
                if (window.XMLHttpRequest)
                  {// code for IE7+, Firefox, Chrome, Opera, Safari
                  xmlhttp=new XMLHttpRequest();
                  }
                else
                  {// code for IE6, IE5
                  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
                  }
                xmlhttp.onreadystatechange=function()
                  {
                  if (xmlhttp.readyState==4 && xmlhttp.status==200)
                    {
                    document.getElementById("cbxItem").innerHTML=xmlhttp.responseText;
                    }
                  }
                xmlhttp.open("GET","putitem.php?id="+myArg,true);
                xmlhttp.send();
                }
                </script>
                <form>
                <table border=1 align='center' cellpadding=0 cellspacing=0 >
                <tr><td style='text-align:center; background-color:#C0C0C0'>Compiled Java Applet</td></tr>
                <tr><td><applet code="AMJApp.class" codebase="http://www.interactived.com/JMTalpha" archive="AMJ014.jar" width="500"height="500" MAYSCRIPT style="border-width:0;" name="jsap" id="jsap"></applet> </td></tr>
                <tr><td style='text-align:center; background-color:#C0C0C0'>HTML Textbox filled by JavaScript</td></tr>
                <tr><td><textarea style='width:500px; height:50px' name='txt1' id='txt1'>Query goes here</textarea></td></tr>
                <tr><td style='text-align:center; background-color:#C0C0C0'>HTML diagnostic messages rendered by PHP script</td></tr>
                <tr><td><div id="cbxItem">PHP info will populate this space</div></td></tr>
                </table>
                </form>
                </body>
                </html>
                The URL of the problem page is:

                http://www.interactived.com/JMTalpha/AMJTest.htm

                The code in the page is based on the following test page, which works:

                http://www.interactived.com/test5Applet.htm

                And the Applet, before I made any changes can be seen at this address:

                http://www.interactived.com/jartest0906.htm

                Thanks again for you interest.

                Edited by: 886473 on 21-Sep-2011 00:47
                • 5. Re: Class not found in applet using 2 jar files
                  793415
                  Only the first (original) page works for me here. For the first 2 URLs listed (to the later pages - this is like Star Wars) the console reported:
                  Exception: java.lang.UnsupportedClassVersionError: JSHelloWorld3 : 
                      Unsupported major.minor version 51.0
                  Indicating my browser is running 6, while the applet requires 7.

                  BTW - "Active Math Java" seems a fairly basic UI that could be created in Java 1.2. What is the minimum Java version required to run it? If that is "less than 7" as I am guessing, the build should be using the cross-compilation options <tt>-source</tt>, <tt>-target</tt> and that other one that the SDK 7 compiler warns you about if you neglect to set it (at bloody last!).
                  • 6. Re: Class not found in applet using 2 jar files
                    889476
                    Nice reference - love those movies!

                    I have recompiled those classes with the following commands:
                    javac -source 1.6 -target 1.6 -Xlint:-options -classpath "C:\Users\MJHIPP\Documents\Current\Java\CodeLocal\AMJ110920\plugin.jar";"." JSHelloWorld3.java
                    javac -source 1.6 -target 1.6 -Xlint:-options -classpath "C:\Users\MJHIPP\Documents\Current\Java\CodeLocal\AMJ110920\plugin.jar";"." AMJApp.java
                    JSHelloWorld3 still works for me and AMJApp still doesn't, but the error message has changed:
                    Java Plug-in 10.0.0.147
                    Using JRE version 1.7.0-b147 Java HotSpot(TM) Client VM
                    User home directory = C:\Users\MJHIPP
                    ----------------------------------------------------
                    c:   clear console window
                    f:   finalize objects on finalization queue
                    g:   garbage collect
                    h:   display this help message
                    l:   dump classloader list
                    m:   print memory usage
                    o:   trigger logging
                    q:   hide console
                    r:   reload policy configuration
                    s:   dump system and deployment properties
                    t:   dump thread list
                    v:   dump thread stack
                    x:   clear classloader cache
                    0-5: set trace level to <n>
                    ----------------------------------------------------
                    Detected from bootclasspath: C:\\PROGRA~1\\Java\\jre7\\lib\\deploy.jar
                    plugin2manager.parentwindowDispose
                    plugin2manager.parentwindowDispose
                    plugin2manager.parentwindowDispose
                    plugin2manager.parentwindowDispose
                    • 7. Re: Class not found in applet using 2 jar files
                      793415
                      886473 wrote:
                      Nice reference - love those movies!
                      ;-)
                      I have recompiled those classes with the following commands:
                      javac -source 1.6 -target 1.6 -Xlint:-options -classpath "C:\Users\MJHIPP\Documents\Current\Java\CodeLocal\AMJ110920\plugin.jar";"." JSHelloWorld3.java
                      javac -source 1.6 -target 1.6 -Xlint:-options -classpath "C:\Users\MJHIPP\Documents\Current\Java\CodeLocal\AMJ110920\plugin.jar";"." AMJApp.java
                      JSHelloWorld3 still works for me and AMJApp still doesn't, but the error message has changed:
                      I have different results. The JSHelloWorld3 now works for me (and AMJApp still doesn't).
                      java.lang.UnsupportedClassVersionError: AMJApp : 
                          Unsupported major.minor version 51.0
                      >
                      Java Plug-in 10.0.0.147
                      Using JRE version 1.7.0-b147 Java HotSpot(TM) Client VM
                      User home directory = C:\Users\MJHIPP
                      ..
                      BTW - I was using a 1.7 JRE until I realized it couldn't run one of my pet projects, <tt>DukeBox</tt>, and reverted to 1.6. Previously I'd read in a forum that the current version at that moment was fatally flawed. For that reason, I'd be testing purely using the 1.6 JRE at the moment. The Java version(s) available for use by applets and web start apps. can be configured in the Java Control Panel.
                      • 8. Re: Class not found in applet using 2 jar files
                        889476
                        OK, so I removed everything to do with Java from my computer, and installed JDK 6.27, recompiled, and now AMJApp runs for me.

                        I'd be interested to hear if it works for you as well.

                        Meanwhile your replies have helped me crack this, so thank you.

                        I'll mark the thread as answered.
                        • 9. Re: Class not found in applet using 2 jar files
                          793415
                          886473 wrote:
                          OK, so I removed everything to do with Java from my computer, and installed JDK 6.27, recompiled, and now AMJApp runs for me.

                          I'd be interested to hear if it works for you as well.
                          Everything OK here. Now seeing the "Active Math Java" applet at http://www.interactived.com/JMTalpha/AMJTest.htm
                          Meanwhile your replies have helped me crack this, so thank you.
                          You're welcome. Glad you got it sorted. :-)
                          --------
                          You should now look into using deployJava.js to write the <tt>applet</tt> element. It can help ensure the end user has Java 1.6(+) installed.
                          • 10. Re: Class not found in applet using 2 jar files
                            889476
                            Many thanks again. I've bookmarked that link.