0
    Exception in thread "main" java.lang.ExceptionInInitializerError
            at org.apache.tools.ant.util.FileUtils.<clinit>(FileUtils.java:63)
            at org.apache.tools.ant.Project.<clinit>(Project.java:131)
            at Pv.plugin_execute(Pv.java:140)
            at Pv.main(Pv.java:194)
    Caused by: java.lang.NullPointerException
            at org.apache.tools.ant.taskdefs.condition.Os.<clinit>(Os.java:31)
            ... 4 more

这是我从 java 文件中运行 ant 目标的代码。我已经为它设置了所有参数。代码在 Linux 环境下运行。

File buildFile = new File(bDir + "/" + pBDir + "/"+ atBFile);
Project p = new Project();
p.setUserProperty("ant.file", buildFile.getAbsolutePath());
p.init();
ProjectHelper helper = ProjectHelper.getProjectHelper();
p.addReference("ant.projectHelper", helper);
helper.parse(p, buildFile);
p.executeTarget(target);

谁能帮我这个?昨天它运行良好,今天它给了我这个例外......

4

2 回答 2

0

问题是,由于我使用的是 System.setProperties() 它删除了现有的属性列表并创建了一个新列表。但是 System.property() 将属性附加到现有列表中。

于 2013-12-09T10:31:01.943 回答
0

鉴于源代码,您似乎由于某种原因没有设置“os.name”的系统属性。您应该查看未设置的原因,但如有必要,您始终可以从命令行手动指定它。

于 2012-10-12T07:16:09.120 回答