Results 1 to 3 of 3
Thread: Create Applet in Eclipse
- 10-19-2010, 10:08 PM #1
Member
- Join Date
- Feb 2009
- Posts
- 5
- Rep Power
- 0
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?
- 10-20-2010, 05:52 PM #2
Member
- Join Date
- Feb 2009
- Posts
- 5
- Rep Power
- 0
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 :)
-
Similar Threads
-
How to create an eclipse editor?
By Rudraraju440059 in forum EclipseReplies: 0Last Post: 08-23-2010, 11:56 AM -
Create Windows, Applet & Swing
By Eric in forum AWT / SwingReplies: 1Last Post: 07-05-2007, 06:36 AM -
Create a Applet in the page HTML
By Daniel in forum Java AppletsReplies: 2Last Post: 07-04-2007, 07:52 AM -
cannot create a new jboss configuration in Eclipse
By Husey in forum EclipseReplies: 5Last Post: 06-15-2007, 01:32 PM -
How To Create EJB’s In Eclipse IDE
By JavaForums in forum EclipseReplies: 0Last Post: 04-26-2007, 10:15 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks