Results 1 to 6 of 6
  1. #1
    BookOfEliX is offline Member
    Join Date
    Feb 2015
    Posts
    20
    Rep Power
    0

    Default Error Can't find symbol

    Whenever i try to compile the code, I get " cannot find symbol". Any suggestions?


    Java Code:
    public class NinePointOne{
    
       public static void main(String[] args){
          Rectangle rec1 = new Rectangle();
    
      }
    }

  2. #2
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,716
    Rep Power
    18

    Default Re: Error Can't find symbol

    What's the full compiler message? It generally says *what* is unknown. Perhaps import Rectangle.

  3. #3
    BookOfEliX is offline Member
    Join Date
    Feb 2015
    Posts
    20
    Rep Power
    0

    Default Re: Error Can't find symbol

    That is the full message. Any suggestions?
    Java Code:
    NinePointOne.java:4: error: cannot find symbol
          Rectangle rec1 = new Rectangle();
          ^
      symbol:   class Rectangle
      location: class NinePointOne
    Last edited by pbrockway2; 03-02-2015 at 05:47 AM. Reason: code tags added

  4. #4
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,716
    Rep Power
    18

    Default Re: Error Can't find symbol

    The message is saying that the compiler doesn't know what the Rectangle class is. You ought to import it. Google "java api docs" if you are unsure which package it belongs to.

  5. #5
    BookOfEliX is offline Member
    Join Date
    Feb 2015
    Posts
    20
    Rep Power
    0

    Default Re: Error Can't find symbol

    But let's say that both Java classes are within the same folder. Would I still need to import it?

  6. #6
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    5,114
    Rep Power
    12

    Default Re: Error Can't find symbol

    Quote Originally Posted by BookOfEliX View Post
    But let's say that both Java classes are within the same folder. Would I still need to import it?
    No, if you did not make any mistakes then you wouldn't need to import anything.

    Pro tip: don't use class names that already exist in the standard JDK. You technically can do that but it tends to lead to horrible confusion.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

Similar Threads

  1. Cannot Find Symbol Error
    By NajwaMy in forum New To Java
    Replies: 8
    Last Post: 07-31-2013, 06:29 PM
  2. Cannot Find Symbol error
    By Humphrey Bogart in forum New To Java
    Replies: 7
    Last Post: 04-23-2013, 08:50 PM
  3. error: cannot find symbol
    By jaster in forum New To Java
    Replies: 6
    Last Post: 11-21-2011, 12:47 AM
  4. error cannot find symbol
    By jcoon3 in forum New To Java
    Replies: 3
    Last Post: 09-27-2009, 10:56 PM
  5. Replies: 9
    Last Post: 10-18-2008, 08:26 PM

Tags for this Thread

Posting Permissions

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