Java项目正在运行,但是当我尝试构建它时,我在startsWith(NetBeans)上有NullPointerException

时间:2011-07-12 09:26:42

标签: java netbeans nullpointerexception

我有下一个问题。当我从NetBeans IDE运行项目时,evrything很好。但是当我尝试构建项目时,我有例外:

Compiling 2 source files to D:\JAVA\Projects\streamer\build\classes
An exception has occurred in the compiler (1.7.0-ea). Please file a bug at the Java Developer Connection (http://java.sun.com/webapps/bugreport)  after checking the Bug Parade for duplicates. Include your program and the following diagnostic in your report.  Thank you.
java.lang.NullPointerException
    at java.lang.String.startsWith(String.java:1433)
    at java.lang.String.startsWith(String.java:1462)
    at com.sun.tools.javac.file.SymbolArchive.addZipEntry(SymbolArchive.java:49)
    at com.sun.tools.javac.file.ZipArchive.<init>(ZipArchive.java:63)
    at com.sun.tools.javac.file.SymbolArchive.<init>(SymbolArchive.java:41)
............
D:\JAVA\Projects\streamer\nbproject\build-impl.xml:603: The following error occurred while executing this line:
D:\JAVA\Projects\streamer\nbproject\build-impl.xml:245: Compile failed; see the compiler error output for details.

我不使用String.startsWith方法,但我在一个地方使用String.indexOf:

int lastIndex = nodeName.indexOf("date",0);
if (lastIndex != -1 || nodeName.equals("birthday")) {
    txt_val = getHash(txt_val,Boolean.TRUE);
} else {
    txt_val = getHash(txt_val,Boolean.FALSE);
}

nodeName不为null。而我无法理解错误在哪里:(

2 个答案:

答案 0 :(得分:1)

您是否故意使用Java 7?试试Java 6 - 它应该更稳定。看这里Change JRE in NetBeans project

答案 1 :(得分:0)

错误在编译器中就像例外情况一样。你为什么使用java 1.7?