#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Posts
    1
    Rep Power
    0

    cannot resolve symbol n declared file


    hey... i'm starting up on java n ran into a little problem

    this is my code
    public class RectangleTest
    {
    public static void main(String[] args)
    {
    System.out.println(new Rectangle(5, 10, 20, 30));
    }
    }
    n its coughing up this problem
    D:\java>javac RectangleTest.java
    .\Rectangle.java:1: class RectangleTest is public, should be declared in a file
    named RectangleTest.java
    public class RectangleTest
    ------^
    RectangleTest.java:5: cannot resolve symbol
    symbol : constructor Rectangle (int,int,int,int)
    location: class Rectangle
    System.out.println(new Rectangle(5, 10, 20, 30));
    ------------------^
    2 errors

    D:\java>
    ne help is appricated
    thanks in advance
    Last edited by KeiTaro; March 22nd, 2003 at 03:40 AM.
  2. #2
  3. No Profile Picture
    Clueless llama
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Feb 2001
    Location
    Lincoln, NE. USA
    Posts
    2,353
    Rep Power
    117
    The first problem is exactly as it says. If you have a public class in a file, the files name MUST be the same as the public class. In your case, the file name must be "RectangleTest.java". Note this is case specific in java. "rectangletest.java" is not the same.

    The second either is a by-product of the first error, or you do not have an import for the Rectangle class. The Rectangle class is contained in a package and the java compiler needs to know where to get it at. See if you hav a line at the top of the source like this:
    Code:
    import java.awt.*;
    
    public class RectangleTest
    {
    public static void main(String[] args)
    {
    System.out.println(new Rectangle(5, 10, 20, 30));
    }
    }
    If not, add it.

    I would suggest some basic java tutorials
    http://java.sun.com/docs/books/tutorial/index.html
    Last edited by Nemi; March 22nd, 2003 at 11:43 AM.

IMN logo majestic logo threadwatch logo seochat tools logo