2

When I want to compile file named SetPoint.java there're errors:

SetPoint.java:5: error: cannot find symbol
        Point point = new Point();
        ^
  symbol:   class Point
  location: class SetPoint
SetPoint.java:5: error: cannot find symbol
        Point point = new Point();
                          ^
  symbol:   class Point
  location: class SetPoint
2 errors

I have this two files (Point.java and SetPoint.java) in folder named xyz. I don't know what I'm doing wrong. If I do the same in IntelliJ it works correctly.

package xyz;

public class Point {
    int coorX;
    int coorY;
}

.

package xyz;

public class SetPoint {
    public static void main(String args[]){
        Point point = new Point();
        point.coorX = 10;
        point.coorY = 20;

        System.out.println("Coordinate of point: ("+point.coorX+", "+point.coorY+")");
    }

}
4
  • So the error is occurring when you compile from the command line? Can you share the command you're using? Commented Oct 17, 2016 at 21:29
  • I used only "javac SetPoint.java". Commented Oct 17, 2016 at 21:39
  • 1
    Yup, then Elliott's answer below is correct :) Commented Oct 17, 2016 at 21:40
  • Possible duplicate of What does a "Cannot find symbol" compilation error mean? Commented Oct 18, 2016 at 0:08

1 Answer 1

3

Compile both java files at the same time,

javac *.java

or

javac SetPoint.java Point.java
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.