Results 1 to 7 of 7
  1. #1
    Master Zero is offline Member
    Join Date
    May 2008
    Posts
    26
    Rep Power
    0

    Default [SOLVED] Please help me understand...

    Hello, this is my first time here and I am in need of dire help. This is my first time coding in java and it has been nothing but a pain thus far. I can run a simple console app, but for some reason, the knowledge of how to run an applet is far beyond me. Two days I have been searching the internet endlessly for some ray of hope, but nothing... Can someone please tell me what I am doing wrong?

    I have the latest versions of both Eclipse and Java on my system. The applet will load find inside Eclipse but fails when it comes to the browser.

    My Class:
    Java Code:
    package helloWorld;
    
    import java.applet.Applet;
    import java.awt.*;
    
    public class HelloWorldApplet extends Applet {
    	/**
    	 * 
    	 */
    	private static final long serialVersionUID = 1L;
    
    	public void paint(Graphics g){
    		g.drawString("Hello World!", 20, 30);
    		this.setBackground(Color.blue);
    	}
    }
    Html:
    Java Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    </head>
    
    <body>
    <applet code="HelloWorld.bin.helloWorld.HelloWorldApplet" width="400" height="200"></applet>
    </body>
    </html>
    Java Console Error:
    Java Code:
    Java Plug-in 1.6.0_05
    Using JRE version 1.6.0_05 Java HotSpot(TM) Client VM
    User home directory = C:\Documents and Settings\Administrator
    ----------------------------------------------------
    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
    p:   reload proxy configuration
    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>
    ----------------------------------------------------
    java.lang.NoClassDefFoundError: HelloWorld/bin/helloWorld/HelloWorldApplet (wrong name: helloWorld/HelloWorldApplet)
    	at java.lang.ClassLoader.defineClass1(Native Method)
    	at java.lang.ClassLoader.defineClass(Unknown Source)
    	at java.security.SecureClassLoader.defineClass(Unknown Source)
    	at sun.applet.AppletClassLoader.findClass(Unknown Source)
    	at java.lang.ClassLoader.loadClass(Unknown Source)
    	at sun.applet.AppletClassLoader.loadClass(Unknown Source)
    	at java.lang.ClassLoader.loadClass(Unknown Source)
    	at sun.applet.AppletClassLoader.loadCode(Unknown Source)
    	at sun.applet.AppletPanel.createApplet(Unknown Source)
    	at sun.plugin.AppletViewer.createApplet(Unknown Source)
    	at sun.applet.AppletPanel.runLoader(Unknown Source)
    	at sun.applet.AppletPanel.run(Unknown Source)
    	at java.lang.Thread.run(Unknown Source)

  2. #2
    sukatoa's Avatar
    sukatoa is offline Senior Member
    Join Date
    Jan 2008
    Location
    Cebu City, Philippines
    Posts
    556
    Rep Power
    7

    Default

    code="HelloWorld.bin.helloWorld.HelloWorldApplet"
    I never used that one before.
    try to put that html beside your HelloWorldApplet.....

    eg: CODE="HelloWorldApplet.class"
    freedom exists in the world of ideas

  3. #3
    Master Zero is offline Member
    Join Date
    May 2008
    Posts
    26
    Rep Power
    0

    Default

    I tired it and it still does not work!

    Can someone tell me what this error means and how to reslove it:
    Java Code:
    java.lang.NoClassDefFoundError: HelloWorldApplet (wrong name: helloWorld/HelloWorldApplet)

  4. #4
    sukatoa's Avatar
    sukatoa is offline Senior Member
    Join Date
    Jan 2008
    Location
    Cebu City, Philippines
    Posts
    556
    Rep Power
    7

    Default

    try to remove that package at the top of your code.

    Have you read about the Applet's Life Cycle?

    Is HelloWorldApplet.java a compilable code?
    is it generates a .class file beside the HelloWorldApplet.java?

    Put your html beside that .class file.

    What have you observe?

    Update us,
    freedom exists in the world of ideas

  5. #5
    Master Zero is offline Member
    Join Date
    May 2008
    Posts
    26
    Rep Power
    0

    Default

    OMG IT WORKS!!! I remove the package but I got a complied error. So I recreated the class without specifying a package and it worked beautifully. Thank you so much for your patience, and guidance.

  6. #6
    danielstoner's Avatar
    danielstoner is offline Senior Member
    Join Date
    Apr 2008
    Location
    Canada
    Posts
    191
    Rep Power
    6

    Default

    If you are happy then mark the thread as SOLVED and give credit to your mentor by bumping up his reputation :)
    Daniel @ [www.littletutorials.com]
    Language is froth on the surface of thought

  7. #7
    Master Zero is offline Member
    Join Date
    May 2008
    Posts
    26
    Rep Power
    0

    Default

    Done, except I don't know how to mark the thread as sloved!

    *Found it.

Similar Threads

  1. help me need to understand queries
    By hossainsadd in forum JDBC
    Replies: 1
    Last Post: 05-26-2008, 12:02 AM
  2. Errors I don't understand
    By MattyB in forum New To Java
    Replies: 4
    Last Post: 04-01-2008, 11:55 PM
  3. New: Want to understand Drawing...
    By diRisig in forum New To Java
    Replies: 1
    Last Post: 02-05-2008, 08:13 AM
  4. i don understand this error
    By Deon in forum New To Java
    Replies: 4
    Last Post: 01-12-2008, 10:03 AM
  5. i can't understand using interface as a type
    By sireesha in forum New To Java
    Replies: 3
    Last Post: 11-20-2007, 10:07 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
  •