java—将ant build.xml导入eclipse时表示在目标“compile”中找不到“javac”任务

rur96b6h  于 2021-06-04  发布在  Hadoop
关注(0)|答案(2)|浏览(399)

我在macosx mountain lion上安装了jdk6,可以直接从eclipse创建新的java项目。
我试图修改alexholmes在json mapreduce上编写的代码(https://github.com/alexholmes/json-mapreduce). 我的第一个目标是将代码引入eclipse构建中,以便调试代码。我做了以下工作:

Launch Eclipse -> File -> New Project -> New project from ant build file 
-> select the build.xml downloaded from the above link

它抛出以下错误:

<> "javac" task not found in target "compile"
<> "java" task not found in target "test"

eclipse显示了代码,但没有进行任何构建或运行任何测试。由于上述错误,似乎出现了一些问题,但是我可以看到在eclipse中创建的其他java项目工作正常。
(eclipse显示安装的jre位置: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home )
谢谢你的建议。

ruarlubt

ruarlubt1#

根据我的经验,ant构建脚本(除非在设计时显式处理)太过松散,无法保证以后的ide轻松集成。
我们尝试使用ant4eclipse让ant编译现有的eclipse项目(通过读取.project和.classpath文件),但它的伸缩性不好。
如果你有时间和政治上的支持,你可能会想切换到maven的规模。但是,如果您当前的构建过程不符合“一个项目,一个结果jar文件”,那么这可能需要相当长的时间。
如果您不这样做,我建议您忘记让eclipse处理build.xml的所有事情,手动维护eclipse项目镜像build.xml配置,并在需要时从命令行运行ant(如果需要,作为远程java应用程序进行调试)。

hmtdttj4

hmtdttj42#

您是否可以尝试在目标中设置java路径,如下所述:

<target name="compile">
  <javac target="1.5" srcdir=.../>
</target>

相关问题