Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Simple applet, but wrong

  1. #1
    Junior Member
    Join Date
    Apr 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Simple applet, but wrong

    I made a simple applet game of pong, but when I try to acces it via html and different browser it says: ClassNotFoundException. I tried a simplier code and got the same message. There in one folder and there I have the files- Main.java and shit.html. Here is the code:

    package GAME;
     
     
    import java.applet.*;
    import java.awt.*;
     
    public class Main extends Applet{
       public void paint(Graphics g){
          g.drawString("Help! I need somebody! Help!",40,20);
       }
    }


    and the html

    HTML Code:
    <HTML>
    <HEAD>
    </HEAD>
    <BODY>
    <div >
    <APPLET CODE="Main.class" WIDTH="800" HEIGHT="500">
    </APPLET>
    </div>
    </BODY>
    </HTML>


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    21,894
    Thanks
    55
    Thanked 2,350 Times in 2,321 Posts

    Default Re: Simple applet, but wrong

    What was the full error message? What was the name of the class that was not found?

    One problem is the class is in a package, so the class's full name includes the package name:
    GAME.Main

    The simplest fix is to remove the package statement.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Simple Applet Troubles
    By Veldimare in forum Java Applets
    Replies: 7
    Last Post: September 22nd, 2012, 06:19 PM
  2. Painfully simple Applet problem.
    By austin.rose94 in forum What's Wrong With My Code?
    Replies: 5
    Last Post: January 4th, 2012, 08:09 AM
  3. I'm either doing this entirely wrong or I'm missing something simple.
    By xionyus in forum What's Wrong With My Code?
    Replies: 1
    Last Post: October 14th, 2011, 09:56 AM
  4. [SOLVED] Help with simple Applet code
    By that_guy in forum What's Wrong With My Code?
    Replies: 13
    Last Post: January 11th, 2011, 10:22 PM
  5. Very beginner - What's wrong in my applet declaration?
    By rforte in forum What's Wrong With My Code?
    Replies: 5
    Last Post: April 30th, 2010, 05:54 AM