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: Main method/ class problem. I can't run any script!

  1. #1
    Junior Member
    Join Date
    Jun 2012
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Main method/ class problem. I can't run any script!

    Hello I am very new to Java and have been using a mix of eclipse and net beans. Just today I have been getting these two errors no matter what script I run. Even if the script is perfectly fine I will get these two errors on both net beans and eclipse. everything has been working fine until today.

    Java version: 7.0.30.5
    net beans version: 7.1.2

    x60lyg.jpg (http://i.imgur.com/BcCfU.png)

    2cr3q7p.jpg (http://i.imgur.com/JoiBl.png)

    Hope someone knows whats wrong. Thanks!

    p.s. I have uninstalled and re installed both java and net beans/ eclipse
    Last edited by BokBok; June 27th, 2012 at 03:00 PM.


  2. #2
    Super Moderator Sean4u's Avatar
    Join Date
    Jul 2011
    Location
    Tavistock, UK
    Posts
    637
    Thanks
    5
    Thanked 103 Times in 93 Posts

    Default Re: Main method/ class problem. I can't run any script!

    Your Test.java source file contains a class called "Hello" - that's wrong, it should be a class called "Test". If you want its full class name to be test.Test, you should have a package declaration at the top of the source file like "package test".
    I have uninstalled and re installed both java and net beans/ eclipse
    But did you try turning your PC off and then on again?

  3. The Following User Says Thank You to Sean4u For This Useful Post:

    BokBok (June 28th, 2012)

  4. #3
    Junior Member
    Join Date
    Jun 2012
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Main method/ class problem. I can't run any script!

    Quote Originally Posted by Sean4u View Post
    Your Test.java source file contains a class called "Hello" - that's wrong, it should be a class called "Test". If you want its full class name to be test.Test, you should have a package declaration at the top of the source file like "package test".

    But did you try turning your PC off and then on again?
    Oh thanks you very much!

  5. #4
    Junior Member
    Join Date
    Jun 2012
    Posts
    18
    Thanks
    2
    Thanked 1 Time in 1 Post

    Default Re: Main method/ class problem. I can't run any script!

    what i think is that it needs
    pacakge test;
    at the top
    Last edited by usama8800; June 28th, 2012 at 05:20 PM.

Similar Threads

  1. Replies: 3
    Last Post: October 31st, 2011, 12:42 AM
  2. Paint program adding classes to main method class
    By Maxfmc in forum What's Wrong With My Code?
    Replies: 0
    Last Post: April 15th, 2011, 07:01 PM
  3. Creating a scaleUp main method in a new class
    By Brainz in forum What's Wrong With My Code?
    Replies: 1
    Last Post: November 16th, 2010, 08:58 AM
  4. Calling a void method into a static void main within same class
    By sketch_flygirl in forum Object Oriented Programming
    Replies: 3
    Last Post: November 15th, 2009, 05:24 PM
  5. Main Class Not Found Problem
    By shadow in forum Java Theory & Questions
    Replies: 3
    Last Post: September 29th, 2009, 09:42 AM