Results 1 to 12 of 12
  1. #1
    kraigballa is offline Senior Member
    Join Date
    Oct 2011
    Posts
    115
    Rep Power
    0

    Default Eclipse Applet not working with Browsers

    [Sorry if there are multiple post in the Java Applets section..when I saw I had posted in the wrong section I went back to copy my post]
    I have searched and searched all over for this, but I have yet to find a solution that works. The Applet works when I Run it in Eclipse, but not when I embed it into an .html file. Below is an image of my directory:



    Here is the Java error message:
    Java Code:
    load: class Welcome.class not found.
    java.lang.ClassNotFoundException: Welcome.class
    	at sun.plugin2.applet.Applet2ClassLoader.findClass(Applet2ClassLoader.java:252)
    	at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Plugin2ClassLoader.java:250)
    	at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Plugin2ClassLoader.java:180)
    	at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Plugin2ClassLoader.java:161)
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
    	at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Plugin2ClassLoader.java:687)
    	at sun.plugin2.applet.Plugin2Manager.createApplet(Plugin2Manager.java:3046)
    	at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Plugin2Manager.java:1498)
    	at java.lang.Thread.run(Thread.java:680)
    Exception: java.lang.ClassNotFoundException: Welcome.class
    I am new to Java and Java Applets so any help would be greatly appreciated. I do have experience in other programming langages though!!

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default Re: Eclipse Applet not working with Browsers

    The class's name and location is not Welcome.class but appletexample/Welcome.class. You can't forget the package name. If your Jar name is AppletTest.jar, I think you would do something like so:

    Java Code:
    <HTML>
    <BODY>
    <APPLET CODE=appletexample/Welcome.class
      ARCHIVE="AppletTest.jar"
      WIDTH=300
      HEIGHT=300>
    </APPLET>
    </BODY>
    </HTML>
    But please note that I'm not an applet expert. Also, if you can avoid posting images and post text more often than not, please do so.

  3. #3
    kraigballa is offline Senior Member
    Join Date
    Oct 2011
    Posts
    115
    Rep Power
    0

    Default Re: Eclipse Applet not working with Browsers

    I tried what you said and now I get:
    Java Code:
    load: class appletexample/Welcome.class not found.
    java.lang.ClassNotFoundException: appletexample.Welcome.class
    	at sun.plugin2.applet.Applet2ClassLoader.findClass(Applet2ClassLoader.java:252)
    	at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Plugin2ClassLoader.java:250)
    	at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Plugin2ClassLoader.java:180)
    	at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Plugin2ClassLoader.java:161)
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
    	at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Plugin2ClassLoader.java:687)
    	at sun.plugin2.applet.Plugin2Manager.createApplet(Plugin2Manager.java:3046)
    	at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Plugin2Manager.java:1498)
    	at java.lang.Thread.run(Thread.java:680)
    Exception: java.lang.ClassNotFoundException: appletexample.Welcome.class
    I will note that image thing for the future. Sometimes it's just easier to show rather than explain.
    Last edited by kraigballa; 10-08-2011 at 01:03 AM.

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default Re: Eclipse Applet not working with Browsers

    What is the full name of your class? Is it in the appletexample package? What is the name of your jar file? Where is the jar file in relation to the html file?

  5. #5
    kraigballa is offline Senior Member
    Join Date
    Oct 2011
    Posts
    115
    Rep Power
    0

    Default Re: Eclipse Applet not working with Browsers

    Ok the directory is this:

    AppletTest (main directory)
    Welcome.html
    Welcome.jar
    /src/ ---> /appletexample/ ---> Welcome.java
    /bin/ ---> /appletexample/ ---> Welcome.class
    ---> java.policy.applet (this is in the bin folder)

    The class is in the appletexample package, and I had the .jar file called testing, but I changed it to Welcome...nothing happened with the change.

  6. #6
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default Re: Eclipse Applet not working with Browsers

    What does Welcome.html look like? And have you checked the contents of the jar file with jar.exe via:

    Java Code:
    jar tf Welcome.jar

  7. #7
    kraigballa is offline Senior Member
    Join Date
    Oct 2011
    Posts
    115
    Rep Power
    0

    Default Re: Eclipse Applet not working with Browsers

    The HTML is this:
    Java Code:
    <HTML>
    <BODY>
    <div align = "center">
    <APPLET CODE="appletexample/Welcome.class"
    	ARCHIVE="AppletTest.jar" 
    	WIDTH = "500" 
    	HEIGHT = "400">
    </APPLET>
    </div>
    </BODY>
    </HTML>
    Then running the .jar:
    Java Code:
    META-INF/MANIFEST.MF
    appletexample/Welcome.class
    appletexample/.DS_Store
    .classpath
    .project

  8. #8
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default Re: Eclipse Applet not working with Browsers

    Regarding
    Java Code:
    ARCHIVE="AppletTest.jar"
    Is the jar file named AppletTest.jar or Welcome.jar?

  9. #9
    kraigballa is offline Senior Member
    Join Date
    Oct 2011
    Posts
    115
    Rep Power
    0

    Default Re: Eclipse Applet not working with Browsers

    I've tried both....right now it is Welcome.jar

    It just doesn't make any sense because I can take the Welcome.html and Welcome.java in the same directory, go to my mac terminal and type in: javac Welcome.java

    Then: appletviewer Welcome.html

    And it shows up just fine, but when I try to view the applet via a web browser it does not work. Does it have something to do with me being on localhost?

  10. #10
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default Re: Eclipse Applet not working with Browsers

    It's just your archive name should reflect the jar name and its relative path to the html file.

  11. #11
    kraigballa is offline Senior Member
    Join Date
    Oct 2011
    Posts
    115
    Rep Power
    0

    Default Re: Eclipse Applet not working with Browsers

    Alright, it is and still no luck. From what I read I think it has something to do with my localhost...and not being signed maybe. However, I'm not sure what to do for that

  12. #12
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default Re: Eclipse Applet not working with Browsers

    Quote Originally Posted by kraigballa View Post
    Alright, it is and still no luck. From what I read I think it has something to do with my localhost...and not being signed maybe. However, I'm not sure what to do for that
    No, it has nothing to do with the applet being signed or localhost business. There's something simple and obvious (if we could only see it) that's off.

Similar Threads

  1. applet not working only when opened in browsers
    By aybeeryu in forum Java Applets
    Replies: 6
    Last Post: 08-11-2011, 11:15 PM
  2. Replies: 1
    Last Post: 08-19-2010, 12:47 PM
  3. Applet working in Eclipse but not in browser
    By leeloo in forum Java Applets
    Replies: 7
    Last Post: 07-05-2010, 01:24 AM
  4. First Applet not running on browsers
    By Centinela66 in forum Java Applets
    Replies: 11
    Last Post: 10-09-2008, 01:58 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
  •