I have compiled the following java file, and added the file path to the classpath. But after calling the class it shows some errors. As I'm new in Java, please help me.
MyQueue2.java
import java.util.PriorityQueue;
import java.util.*;
public class MyQueue2 {
Comparator<Double> c;
PriorityQueue<Double> PQ;
public MyQueue2() {
c = new Comparator<Double>(){
public int compare(Double o1, Double o2){
if(o2 > o1) {
return -1;
} else if(o1 > o2) {
return 1;
} else {
return 0;
}
}
};
PQ = new PriorityQueue<Double>(1000,c);
}
public void addElement(double d) {
PQ.add(d);
}
public double removeElement() {
return(PQ.remove());
}
}
My commands in MATLAB:
import java.util.PriorityQueue;
import java.util.*;
import MyQueue2;
methods('MyQueue2') %
Methods for class MyQueue2:
MyQueue2 equals hashCode notifyAll toString
addElement getClass notify removeElement wait
a = MyQueue2
Java exception occurred:
java.lang.NoClassDefFoundError: MyQueue2$1
at MyQueue2.<init>(MyQueue2.java:9)
Caused by: java.lang.ClassNotFoundException: MyQueue2$1
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at com.mathworks.jmi.CustomURLClassLoader.findClass(ClassLoaderManager.java:760)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
... 1 more
b = MyQueue2 % again
Java exception occurred:
java.lang.NoClassDefFoundError: MyQueue2$1
at MyQueue2.<init>(MyQueue2.java:9)
Please help me to solve the problem.