Results 1 to 4 of 4
  1. #1
    Sunshine68 is offline Member
    Join Date
    Jan 2013
    Posts
    2
    Rep Power
    0

    Default Error while Compiling

    This is an error that I can't figure out what I did wrong.

    C:\Program Files\Java\jdk1.7.0_11\bin>javac Person2.java
    Person2.java:1: error: class, interface, or enum expected public Class Person2TestDrive {
    ^
    Person2.java:2: error: class, interface, or enum expected public static void main<String[] args) {
    ^
    Person2.java:4: error: class, interface, or enum expected p.firstname = "Debbie";
    ^
    Person2.java:5: error: class, interface, or enum expected p.age = 20;
    ^

    They all seem to be the same error.

    I would appreciate any suggestions.

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default Re: Error while Compiling

    Class isn't a Java keyword; class is.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    Sunshine68 is offline Member
    Join Date
    Jan 2013
    Posts
    2
    Rep Power
    0

    Default Re: Error while Compiling

    I replaced the Class with class. These are the errors I have now:(

    c:\Program Files\Java\jdk1.7.0_11\bin>javac Person2.java
    Person2.java:1: error: class Person2TestDrive is public, should be declared in a
    file named Person2TestDrive.java
    public class Person2TestDrive {
    ^
    .\Person.java:3: error: ';' expected
    String First Name;
    ^
    .\Person.java:3: error: <identifier> expected
    String First Name;
    ^
    .\Person.java:4: error: ';' expected
    String Last Name;
    ^
    .\Person.java:4: error: <identifier> expected
    String Last Name;
    ^
    .\Person.java:15: error: class PersonTestDrive is public, should be declared in
    a file named PersonTestDrive.java
    public class PersonTestDrive {
    ^
    .\Person.java:3: error: cannot find symbol
    String First Name;
    ^
    symbol: class Name
    location: class Person
    .\Person.java:4: error: cannot find symbol
    String Last Name;
    ^
    symbol: class Name
    location: class Person
    Person2.java:4: error: cannot find symbol
    p.firstname = "Debbie";
    ^
    symbol: variable firstname
    location: variable p of type Person
    Person2.java:5: error: cannot find symbol
    p.lastname = "Morin";
    ^
    symbol: variable lastname
    location: variable p of type Person
    Person2.java:7: error: cannot find symbol
    p.gender = "Female";
    ^
    symbol: variable gender
    location: variable p of type Person
    Person2.java:8: error: cannot find symbol
    p.ssn = 000-000-0000;
    ^
    symbol: variable ssn
    location: variable p of type Person
    .\Person.java:17: error: cannot find symbol
    Person p = new person();
    ^
    symbol: class person
    location: class PersonTestDrive
    .\Person.java:18: error: package p does not exist
    p.first name = "Debbie";
    ^
    .\Person.java:19: error: package p does not exist
    p.last name = "Morin";
    ^
    .\Person.java:21: error: cannot find symbol
    p.gender = "Female";
    ^
    symbol: variable gender
    location: variable p of type Person
    .\Person.java:22: error: cannot find symbol
    p.ssn = 000-000-0000;
    ^
    symbol: variable ssn
    location: variable p of type Person
    17 errors

    c:\Program Files\Java\jdk1.7.0_11\bin>

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default Re: Error while Compiling

    Take it from the top.

    Quote Originally Posted by Sunshine68 View Post
    class Person2TestDrive is public, should be declared in a file named Person2TestDrive.java
    I don't think I can rephrase that to be any clearer than it already is.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Error Compiling Need Help
    By RebellionX in forum New To Java
    Replies: 4
    Last Post: 05-27-2012, 06:26 PM
  2. Compiling error
    By efth in forum New To Java
    Replies: 8
    Last Post: 04-10-2011, 04:14 PM
  3. Compiling Error
    By kartikeyasri in forum New To Java
    Replies: 1
    Last Post: 12-28-2010, 04:20 PM
  4. dos compiling error msg.
    By gatehrdy in forum New To Java
    Replies: 22
    Last Post: 09-01-2010, 12:06 AM
  5. Error while compiling
    By ai_2007 in forum Advanced Java
    Replies: 1
    Last Post: 07-01-2007, 11:37 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •