Eclipse中的Ant需要tools.jar,但是Java 9/10中没有tools.jar

时间:2018-08-22 13:17:21

标签: java eclipse javafx ant java-10

我正在尝试使用build.fxbuild文件在e(fx)clipse中构建JavaFX应用程序。不幸的是,蚂蚁抱怨说找不到tools.jar。但是tools.jar是从Java 9开始删除的(实际上我是在使用Java 10),因此无法将其添加到Preferences > Ant > Runtime > Classpath中的ant classpath中。控制台上的实际错误消息是:

BUILD FAILED
<project_directory>\build\build.xml:59: Unable to find a javac compiler;
com.sun.tools.javac.Main is not on the classpath.
Perhaps JAVA_HOME does not point to the JDK.
It is currently set to "C:\Program Files\Java\jre-10.0.1"

我的JAVA_HOME环境变量也设置为指向JDK 10,它也包含在PATH中,所以我也不理解最后一行。在这种情况下我该怎么办?

2 个答案:

答案 0 :(得分:1)

TL;DR - update your Eclipse / e(fx)clipse installation.

According1 to this blog posting e(fx)clipse 3.0.0 supports Java 9. (Apparently a lot of changes were required to get rid of dependencies on Oracle implementation classes.)

The Eclipse project page for e(fx)clipse 3.0.0 says that:

  • it was released in June 2017
  • it is part of the Oxygen release(s)

There is no specific mention of releases supporting Java 10 or later (yet), but another blog post talks about how e(fx)clipse will have to cope with JavaFX11 being unbundled from the standard Java SE distributions.


1 - I am not in a position to validate this information ...

答案 1 :(得分:0)

您使用的是旧版的eclipse还是JAVA_HOME不正确?

  • 首先,下载并使用Java 9或10 JDK
  • 正确设置环境变量(不要使用JRE位置),
  • 更新您的路径以将bin文件夹包括在JDK文件夹中
  • 确保您拥有eclipse的最新版本