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

    Default Create Applet in Eclipse

    Hello,
    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:

    02_Project
    -> Java Resources: src
    ---> (default package)
    ------> Customer2.java
    ---> 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 unnable.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
    Caused by: java.io.IOException: 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$1.run(Unknow n Source)
    at java.security.AccessController.doPrivileged(Native Method)
    ... 9 more
    Exception: java.lang.ClassNotFoundException: Customer2.class


    Organization of files on server:

    02_Project
    -> 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
    Posts
    5
    Rep Power
    0

    Default

    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
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

Similar Threads

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