为什么这个教科书程序不能识别我的 Point2D 对象?
Why doesn’t this textbook program recognise my Point2D objects?
我正在学习的教科书中提供了以下程序。它应该使用 Point2D class:
计算两个坐标 (x1, y1) 和 (x2, y2) 之间的距离
import java.util.Scanner;
import javafx.geometry.Point2D;
public class TestPoint2D {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("Enter point1's x-, y-coordinates");
double x1 = input.nextDouble();
double y1 = input.nextDouble();
System.out.print("Enter point2's x-, y coordinates");
double x2 = input.nextDouble();
double y2 = input.nextDouble();
Point2D p1 = new Point2D(x1, y2);
Point2D p2 = new Point2D(x2, y2);
System.out.println("p1 is " + p1.toString());
System.out.println("p2 is " + p2.toString());
System.out.println("The distance between p1 and p2 is " +
p1.distance(p2));
}
}
我已经检查了很多很多次,并确保它被正确复制了。当我尝试在终端中编译程序时,出现以下错误消息:
import javafx.geometry.Point2D;
^
TestPoint2D.java:15: error: cannot find symbol
Point2D p1 = new Point2D(x1, y2);
^
symbol: class Point2D
location: class TestPoint2D
TestPoint2D.java:15: error: cannot find symbol
Point2D p1 = new Point2D(x1, y2);
^
symbol: class Point2D
location: class TestPoint2D
TestPoint2D.java:16: error: cannot find symbol
Point2D p2 = new Point2D(x2, y2);
^
symbol: class Point2D
location: class TestPoint2D
TestPoint2D.java:16: error: cannot find symbol
Point2D p2 = new Point2D(x2, y2);
^
symbol: class Point2D
location: class TestPoint2D
5 errors
为什么程序无法识别新的 Point2D 对象?
您缺少的是 JavaFX 运行时 jar 的 jar,请在 SO 上参考此问题
What's the location of the JavaFX runtime JAR file, jfxrt.jar, on Linux?
详细解释了jfxrt.jar在Java7和8的位置
希望对您有所帮助!!
我正在学习的教科书中提供了以下程序。它应该使用 Point2D class:
计算两个坐标 (x1, y1) 和 (x2, y2) 之间的距离import java.util.Scanner;
import javafx.geometry.Point2D;
public class TestPoint2D {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("Enter point1's x-, y-coordinates");
double x1 = input.nextDouble();
double y1 = input.nextDouble();
System.out.print("Enter point2's x-, y coordinates");
double x2 = input.nextDouble();
double y2 = input.nextDouble();
Point2D p1 = new Point2D(x1, y2);
Point2D p2 = new Point2D(x2, y2);
System.out.println("p1 is " + p1.toString());
System.out.println("p2 is " + p2.toString());
System.out.println("The distance between p1 and p2 is " +
p1.distance(p2));
}
}
我已经检查了很多很多次,并确保它被正确复制了。当我尝试在终端中编译程序时,出现以下错误消息:
import javafx.geometry.Point2D;
^
TestPoint2D.java:15: error: cannot find symbol
Point2D p1 = new Point2D(x1, y2);
^
symbol: class Point2D
location: class TestPoint2D
TestPoint2D.java:15: error: cannot find symbol
Point2D p1 = new Point2D(x1, y2);
^
symbol: class Point2D
location: class TestPoint2D
TestPoint2D.java:16: error: cannot find symbol
Point2D p2 = new Point2D(x2, y2);
^
symbol: class Point2D
location: class TestPoint2D
TestPoint2D.java:16: error: cannot find symbol
Point2D p2 = new Point2D(x2, y2);
^
symbol: class Point2D
location: class TestPoint2D
5 errors
为什么程序无法识别新的 Point2D 对象?
您缺少的是 JavaFX 运行时 jar 的 jar,请在 SO 上参考此问题 What's the location of the JavaFX runtime JAR file, jfxrt.jar, on Linux?
详细解释了jfxrt.jar在Java7和8的位置
希望对您有所帮助!!