0
当我运行程序时,得到java.lang.NoClassDefFoundError异常。我曾在多台电脑上尝试过,但仍然出现相同的错误。我有定义的类我仍然可以找到任何人都可以帮助我的错误?没有类Def的发现错误
public class PostfixDriver {
public static void main(String[] args) {
System.out.println("Testing postfix expressions with\n" +
"a = 2.0, b = 3.0, c = 4.0, d = 5.0\n");
testPostfix("a+b");
testPostfix("a-b+c*d");
testPostfix("(a+b)*c-d");
testPostfix("a+b*(c-d)");
testPostfix("(a+b)/(c-d)");
testPostfix("a*(b/(c-d))");
} // end main
public static void testPostfix(String infixExpression) {
String postfixExpression = Postfix.convertToPostfix(infixExpression);
System.out.println("Infix: " + infixExpression);
System.out.println("Postfix: " + postfixExpression);
System.out.println("Value: " +
Postfix.evaluatePostfix(postfixExpression));
System.out.println();
} // end testPostfix
} // end PostfixDriver
这是完全错误
Exception in thread "main" java.lang.NoClassDefFoundError: Postfix
at PostfixDriver.testPostfix(PostfixDriver.java:17)
at PostfixDriver.main(PostfixDriver.java:8)
Caused by: java.lang.ClassNotFoundException: Postfix
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
它说这是从后缀来这是具有converttoPostfix阶级和一切是一样的。如果需要,我可以将它张贴。
Postfix.java
public static String convertToPostfix(String infix) {
ArrayStack operator = new ArrayStack();
String item;
String postfixe;
Object top;
for(int i = 0; infix.length() >= 0; i++){
item.charAt(i);
if (Postfix.isVariable(item.charAt(i))){
postfixe.concat(item.toString());
}
else if (item.charAt(i) == '('){
operator.push(item);
}
else if (item.charAt(i) == ')'){
Postfix.concat(item.toString());
while(!top.equals('(')){
postfixe.concat(item.toString());
top = operator.pop();
}
}
else {
while(!operator.isEmpty()){
top = operator.peek();
if(Postfix.getPrecedence(item.charAt(i)) <= (Character)top){
postfixe.concat(item);
operator.pop();
}
else {
break;
}
operator.push(item);
}
}
}
while(!operator.isEmpty()){
top = operator.pop();
Postfix.concat(item);
}
return postfixe;
} // end convertToPostfix
'Postfix'类在哪里? –
它与PostfixDriver.java在同一个文件夹中 – thechamp
[为什么我在Java中得到一个NoClassDefFoundError?](https://stackoverflow.com/questions/34413/why-am-i-getting-a-noclassdeffounderror -in-JAVA) –