Results 1 to 3 of 3
  1. #1
    spac is offline Member
    Join Date
    Feb 2009
    Rep Power

    Default Create Applet in Eclipse

    I need help with creating an applet in eclipse.
    When I try to run applet via Run/Run as Applet everything is OK.
    But when I create HTML file that call an applet, applet is not displayed.
    I think the problem is in navigating to class file in html applet tag.
    I use Glassfish v3 server.

    My applet tag is:

    <applet code="Customer2.class" width="400" height="300"></applet>

    Organization of project in eclipse looks as follows:

    -> Java Resources: src
    ---> (default package)
    ---> Libraries
    -> JavaScript Resources
    -> build
    -> Web Content
    ---> META-INF
    ------> MANIFEST.MF
    ---> WEB-INF
    ------> lib
    ------> sun-web.xml
    ---> Customer2.html

    When I try "Run/Run on Server" or try open it in web browser (mozilla or ie) through "http://localhost:8080/02_Chapter/Customer2.html", only rectangle was displayed and it announce "Error. Click for details". Details produce this:

    load: class Customer2.class not found.
    java.lang.ClassNotFoundException: Customer2.class
    at sun.plugin2.applet.Applet2ClassLoader.findClass(Un known Source)
    at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(U nknown Source)
    at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Un known Source)
    at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Un known Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unk nown Source)
    at sun.plugin2.applet.Plugin2Manager.createApplet(Unk nown Source)
    at sun.plugin2.applet.Plugin2Manager$AppletExecutionR Source)
    at Source)
    Caused by: open HTTP connection failed:http://localhost:8080/02_Chapter/Customer2/class.class
    at sun.plugin2.applet.Applet2ClassLoader.getBytes(Unk nown Source)
    at sun.plugin2.applet.Applet2ClassLoader.access$000(U nknown Source)
    at sun.plugin2.applet.Applet2ClassLoader$ n Source)
    at Method)
    ... 9 more
    Exception: java.lang.ClassNotFoundException: Customer2.class

    Organization of files on server:

    -> META-INF
    ----> MANIFEST.MF
    -> WEB-INF
    ----> classes
    -------> Customer2.class
    ----> lib
    ----> sun-web.xml
    -> Customer2.html

    When I put html and .class files at desktop and open html file, applet was loaded correctly. This is reason why i think that problem is in navigation to .class file in applet tag...
    Could somebody explain me what I'm doing wrong?

  2. #2
    spac is offline Member
    Join Date
    Feb 2009
    Rep Power


    I solve this problem with this solution:

    right click at name of project 02_Project/Properties/Java Build Path

    and in Source tab I set the default output folder to "02_Project/WebContent/classes"

    in html I define applet tag as <applet code="Customer2" codebase="/02_Project/classes" width="400" height="300"></applet>

    and it finally works :)

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Blog Entries
    Rep Power

Similar Threads

  1. How to create an eclipse editor?
    By Rudraraju440059 in forum Eclipse
    Replies: 0
    Last Post: 08-23-2010, 12:56 PM
  2. Create Windows, Applet & Swing
    By Eric in forum AWT / Swing
    Replies: 1
    Last Post: 07-05-2007, 07:36 AM
  3. Create a Applet in the page HTML
    By Daniel in forum Java Applets
    Replies: 2
    Last Post: 07-04-2007, 08:52 AM
  4. Replies: 5
    Last Post: 06-15-2007, 02:32 PM
  5. How To Create EJB’s In Eclipse IDE
    By JavaForums in forum Eclipse
    Replies: 0
    Last Post: 04-26-2007, 11:15 AM

Posting Permissions

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