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 4 of 4

Thread: Java newbie...Help required

  1. #1
    Junior Member
    Join Date
    Aug 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Java newbie...Help required

    Hi i'm trying to grasp Java via reading tutorials..

    I'm trying to setup a small quiz but getting nowhere..

    My code is below
    ================================================== =======
    package footballquiz;

    import java.applet.*;
    import java.awt.*;
    import javax.swing.*;

    public class Main {
    private static void createAndShowGUI() {
    //Create window
    JFrame frame = new JFrame("main");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOS E);

    JLabel emptyLabel = new JLabel("main");
    emptyLabel.setPreferredSize(new Dimension(175, 100));
    frame.getContentPane().add(emptyLabel, BorderLayout.CENTER);

    //Display Window
    //Display the window.
    frame.pack();
    frame.setVisible(true);
    javax.swing.SwingUtilities.invokeLater(new Runnable() {
    public void run() {
    createAndShowGUI();
    }
    });
    }
    }
    ================================================

    when running i get the following error..

    "Footballquiz.Main class wasn't found in FootballQuiz project"

    Can anyone shed light on this please.... and point me in the right direction...

    Thanks in advance


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Java newbie...Help required

    Can you copy and paste here the full contents of the console.
    You post shows different case for the package and the error message. java is case sensitive. Make sure the the names match.

    If this is an IDE question, I have no idea how to fix it.

  3. #3
    Forum VIP
    Join Date
    Jul 2010
    Posts
    1,676
    Thanks
    25
    Thanked 329 Times in 305 Posts

    Default Re: Java newbie...Help required

    What is the name of your class you are in? Because if you named it something other than Main, you will have an issue. In Java, the class you are in has to be the name of the .java file.

    When you say:
    public class Main {
    It will look to see if you are in the Main class. If you are not, it will throw an exception.

    My guess is the name of your file is Footballquiz and the compiler is attempting to create Main as an inner class (which would be named Footballquiz$Main.class or something)

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Java newbie...Help required

    See second thread at http://www.javaprogrammingforums.com...-required.html

Similar Threads

  1. JAVA Coder required urgently-paid
    By sam_java in forum Paid Java Projects
    Replies: 2
    Last Post: January 15th, 2011, 04:04 AM
  2. Java Career Advice required
    By saads90 in forum The Cafe
    Replies: 1
    Last Post: April 26th, 2010, 08:59 AM
  3. Java Web Developer Required, South East London / Kent
    By ronsterchan in forum Paid Java Projects
    Replies: 0
    Last Post: March 16th, 2010, 09:00 AM
  4. Java Developer Required in Essex
    By Paul in forum Paid Java Projects
    Replies: 2
    Last Post: March 3rd, 2010, 05:10 AM
  5. Please help required with Java Algoritham Programming
    By simply_stunning79 in forum Algorithms & Recursion
    Replies: 1
    Last Post: February 22nd, 2010, 07:42 PM