java.lang.ExceptionInInitializerError异常

时间:2012-10-12 07:12:12

标签: java ant

    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);

任何人都可以帮我吗?昨天它运行正常,今天它给了我这个例外...

2 个答案:

答案 0 :(得分:0)

鉴于the source code,您似乎没有&#34; os.name&#34;的系统属性。由于某种原因设定。您应该查看为什么未设置,但您可以随时从命令行手动指定它。

答案 1 :(得分:0)

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