Im getting the java.lang.NoClassDefFoundError exception when i run the program. I have tried it on multiple computers and still get the same error. I have the classes defined I still can find the error can anyone help me?
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
this is the full error
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)
It is saying it is coming from Postfix which is the class that has the converttoPostfix and all that is the same.. I can post it if needed.
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