Results 1 to 5 of 5
  1. #1
    CaptainBeer is offline Member
    Join Date
    Apr 2011
    Posts
    3
    Rep Power
    0

    Question Constructor: Cannot find symbol compile error.

    Hi! I compiled my code in jdk1.5 and it worked but when I compiled it in jdk1.6 it did not. So far jdk1.6 gave me 16 errors like this one:

    cannot find symbol
    symbol: class Circle
    class TestCircle extends Circle

    -------------------------Code----------------------


    import javax.swing.*;
    class TestCircle extends Circle

    {
    public static void main(String[]args)
    {
    TestCircle c1 = new TestCircle();
    TestCircle c2 = new TestCircle();
    TestCircle c3 = new TestCircle();

    c1.setRadius(5);
    c2.setRadius(10);
    c3.getRadius(1);

    c1.computeDiameter();
    c1.computeArea();

    c2.computeDiameter();
    c2.computeArea();

    c3.computeDiameter();
    c3.computeArea();

    JOptionPane.showMessageDialog(null, "Diameter: "+c1.diameter,"Circle 1", JOptionPane.INFORMATION_MESSAGE);
    JOptionPane.showMessageDialog(null, "Area: "+c1.area,"Circle 1", JOptionPane.INFORMATION_MESSAGE);

    JOptionPane.showMessageDialog(null, "Diameter: "+c2.diameter,"Circle 2", JOptionPane.INFORMATION_MESSAGE);
    JOptionPane.showMessageDialog(null, "Area: "+c2.area,"Circle 2", JOptionPane.INFORMATION_MESSAGE);

    JOptionPane.showMessageDialog(null, "Diameter: "+c3.diameter,"Circle 3", JOptionPane.INFORMATION_MESSAGE);
    JOptionPane.showMessageDialog(null, "Area: "+c3.area,"Circle 3", JOptionPane.INFORMATION_MESSAGE);
    }
    }

    ------------

    class Circle
    {
    double radius, diameter, area;


    Circle()
    {
    radius = 1;
    }

    void setRadius(double r)
    {
    this.radius = r;
    }

    double getRadius()
    {
    return radius;
    }

    double computeDiameter()
    {
    diameter = radius*2;
    return diameter;
    }

    double computeArea()
    {
    area = (radius*radius)*3.14;
    return area;
    }
    }
    -------------------------

    Can anyone tell me what's wrong? Thank you.

  2. #2
    ozzyman's Avatar
    ozzyman is offline Senior Member
    Join Date
    Mar 2011
    Location
    London, UK
    Posts
    797
    Blog Entries
    2
    Rep Power
    4

    Default

    Compile Circle first before you compile the other class

  3. #3
    CaptainBeer is offline Member
    Join Date
    Apr 2011
    Posts
    3
    Rep Power
    0

    Default

    Thanks for your reply. I already did that, Circle compiled with no errors but after compiling TestCircle, it still gives me 16 errors.

  4. #4
    CaptainBeer is offline Member
    Join Date
    Apr 2011
    Posts
    3
    Rep Power
    0

    Default

    I compiled a simple "Hello World" code. After running it, this is what I got



    Is there something wrong with my jdk?
    Last edited by CaptainBeer; 04-28-2011 at 11:06 AM.

  5. #5
    DarrylBurke's Avatar
    DarrylBurke is online now Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,254
    Rep Power
    19

    Default

    Try this:
    Java Code:
    java -cp . Hello
    Note there's a space-dot-space between -cp and Hello. If that works, add a "." to the CLASSPATH system variable (or better still get rid of the CLASSPATH variable altogether, unless you've installed some Java or JVM related program that needs it).

    db

Similar Threads

  1. overridding constructor causes can not find symbol
    By bflhr673 in forum New To Java
    Replies: 5
    Last Post: 07-27-2010, 10:36 AM
  2. cannot find symbol constructor
    By daud in forum New To Java
    Replies: 9
    Last Post: 08-13-2009, 03:53 AM
  3. Replies: 9
    Last Post: 10-18-2008, 08:26 PM
  4. "Cannont find symbol Constructor" error
    By Welsh in forum New To Java
    Replies: 7
    Last Post: 01-25-2008, 12:12 AM
  5. Error: cannot find symbol constructor
    By zoe in forum New To Java
    Replies: 1
    Last Post: 07-24-2007, 08:24 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
  •