简体   繁体   中英

Compiling java code error

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+")");
    }

}

Compile both java files at the same time,

javac *.java

or

javac SetPoint.java Point.java

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM