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

Thread: Class Error

  1. #1
    Junior Member
    Join Date
    Jul 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Class Error

    Hi Everyone . I'm beginner in Java and use Ubuntu 11.4

    I created Class Event and Then Create UseSimpleEvent File For Create object (Created 2 File ) .
    public class Event
      {
         private int eventGuests;
         public void  displayEventGuests()
                  {
                    JOptionPane.showMessageDialog(null, "Event Guests :"+ eventGuests); 
                   }
        public void inputEventGuests()
                   {
                    char inChar;
                    String guestsString = new String("");
                    guestsString = JOptionPane.showInputDialog(null,
                            "Enter the Number of guests at your Event ");
                    eventGuests = Integer.parseInt(guestsString);
                    }
      }
     
    public class UseSimpleEvent {
     
     
        public static void main(String[] args) {
            Event anEvent = new Event();
            anEvent.inputEventGuests();
            anEvent.displayEventGuests();
     
        }
    }

    I can compile Event.java without Error , but When I want to compile UseSimpleEvent.java my compiler return Error That

    UseSimpleEvent.java:5: cannot find symbol
    symbol : class Event
    location: class UseSimpleEvent
    Event anEvent = new Event();
    ^
    UseSimpleEvent.java:5: cannot find symbol
    symbol : class Event
    location: class UseSimpleEvent
    Event anEvent = new Event();
    ^
    2 errors


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

    Default Re: Class Error

    You should not name your classes with a Java SE class name.
    Make your name unique by adding My: MyEvent.

    Did you post ALL of the code for the two classes? Or did you leave some statements off?

    Without all the code, its hard to see what is happening.

  3. #3
    Junior Member
    Join Date
    Jul 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Class Error

    Yes I posted All Code . my program work in windows , but problem accrue in linux

  4. #4
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: Class Error

    This thread has been cross posted here:

    http://www.java-forums.org/new-java/46916-java-class-error.html

    Although cross posting is allowed, for everyone's benefit, please read:

    Java Programming Forums Cross Posting Rules

    The Problems With Cross Posting

    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

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

    Default Re: Class Error

    Yes I posted All Code
    Your posted code does not have the import statements needed.
    You need to post ALL of your code.

  6. #6
    Junior Member
    Join Date
    Jul 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Class Error

    I Test this 2 class in Microsoft windows and compile without Error , But when use linux system I cannot compile UseSimpleEvent .

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

    Default Re: Class Error

    Are you using the same version of the javac command on the different computers?

    The code you posted will NOT compile because the import statement needed for the JOptonPane class is not there.
    You must be using some IDE that automatically supplies missing code when it does a compile.

Similar Threads

  1. Replies: 2
    Last Post: February 28th, 2011, 10:51 AM
  2. Public class help/error
    By Plural in forum What's Wrong With My Code?
    Replies: 5
    Last Post: October 11th, 2010, 05:22 PM
  3. Keyboard.class error
    By block g raptor in forum What's Wrong With My Code?
    Replies: 2
    Last Post: April 23rd, 2010, 01:37 AM
  4. PayCheck class... percision error.. help!
    By ber1023 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: October 19th, 2009, 03:31 PM
  5. Truncated class file error
    By Koâk in forum Exceptions
    Replies: 4
    Last Post: June 23rd, 2009, 11:23 AM