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

Thread: Please! Help me to this error "ERROR CANNOT FIND SYMBOL"

  1. #1
    Junior Member
    Join Date
    Jul 2012
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Please! Help me to this error "ERROR CANNOT FIND SYMBOL"

    Hello,
    Please help me to correct my error say "ERROR CANNOT FIND SYMBOL".
    i'm new to java..
    this is my code

    public class TestTV {
    	public static void main(String[] args) {
    	TV tv1 = new TV();
    	tv1.onTV();
    	tv1.setChannel(5);
    	tv1.ChannelUp();
    	System.out.printIn ("I'm now on channel:" + tv1.getChannel() );
    	tv1.ChannelDown();
    	tv1.ChannelDown();
    	System.out.printIn ("I'm now on channel:" + tv1.getChannel() );
    	tv1.VolumeUp();
    	tv1.VolumelUp();
    	System.out.printIn ("My volume is now at:" + tv1.getVolume() );
    	tv1.VolumeDown();
    	System.out.printIn ("My volume is now at:" + tv1.getVolume() );
    	tv1.offTV();
    	}
    }

    the error is in the TV tv1 = new TV();
    this is the screenshot.
    error.jpg!
    i need an answer ASAP..

    thank you for your help


  2. #2
    Member
    Join Date
    Jan 2012
    Location
    Hellas
    Posts
    284
    Thanks
    11
    Thanked 59 Times in 57 Posts

    Default Re: Please! Help me to this error "ERROR CANNOT FIND SYMBOL"

    Hello mharck!
    The error message you get is pretty clear, the compiler cannot find the TV class. Where is the TV definition? Is it in another package than the TestTV?

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

    Default Re: Please! Help me to this error "ERROR CANNOT FIND SYMBOL"

    yup..why? what should i do?

  4. #4
    Member
    Join Date
    Jan 2012
    Location
    Hellas
    Posts
    284
    Thanks
    11
    Thanked 59 Times in 57 Posts

    Default Re: Please! Help me to this error "ERROR CANNOT FIND SYMBOL"

    Quote Originally Posted by mharck View Post
    yup..why? what should i do?
    Where is the TV class definition? It should be in the same folder with TVTest.

  5. #5
    Junior Member
    Join Date
    Jul 2012
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Please! Help me to this error "ERROR CANNOT FIND SYMBOL"

    it's in the same folder

  6. #6
    Member
    Join Date
    Jan 2012
    Location
    Hellas
    Posts
    284
    Thanks
    11
    Thanked 59 Times in 57 Posts

    Default Re: Please! Help me to this error "ERROR CANNOT FIND SYMBOL"

    Quote Originally Posted by mharck View Post
    it's in the same folder
    Is the TV class in a package?

  7. #7
    Junior Member
    Join Date
    Jul 2012
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Please! Help me to this error "ERROR CANNOT FIND SYMBOL"

    sorry, but what do you mean?

  8. #8
    Member
    Join Date
    Jan 2012
    Location
    Hellas
    Posts
    284
    Thanks
    11
    Thanked 59 Times in 57 Posts

    Default Re: Please! Help me to this error "ERROR CANNOT FIND SYMBOL"

    Quote Originally Posted by mharck View Post
    sorry, but what do you mean?
    For example:

    package tv; // this means the class is inside the tv package (you give it the name you want)
     
    public class TV{
        .....
    }
    If you are using packaging, then both of your classes should be in the same package.
    ie:

    package tv;  
     
    public class TestTV{
        .....
    }

    I just noticed you execute javac in src\TestTv.java
    If the classes are in the src folder then the current directory needs to be src. And then execute the javac TestTv.java

  9. #9
    Member
    Join Date
    Jul 2012
    Posts
    119
    Thanks
    0
    Thanked 19 Times in 19 Posts

    Default Re: Please! Help me to this error "ERROR CANNOT FIND SYMBOL"

    mharck,
    if you don't need a "package" because of just a test you have to include the directory where your TV.class is stored in your environment variable CLASSPATH.

Similar Threads

  1. "Cannot find symbol" compilation error
    By collegejavastudent in forum What's Wrong With My Code?
    Replies: 7
    Last Post: December 12th, 2011, 05:07 PM
  2. Replies: 3
    Last Post: December 7th, 2011, 02:03 AM
  3. Replies: 7
    Last Post: August 13th, 2011, 01:22 AM
  4. Replies: 6
    Last Post: November 12th, 2010, 04:40 AM
  5. Replies: 1
    Last Post: March 31st, 2010, 09:42 PM