I am trying to run my linked list in a main method, but for some reason I keep getting the following output from my terminal
Exception in thread "main" java.lang.NoClassDefFoundError: PhoneBook/java
Caused by: java.lang.ClassNotFoundException: PhoneBook.java
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Below I have listed the part of my class where I run the main method. Everything compiles fine, but when I run it I get that exception. Is there away I can try/catch the exception? Or is there something I am doing wrong?
import java.util.LinkedList;
public class PhoneBook<T> extends LinkedList<T>{
/**
* Creates two books, adds a person to each book, then prints out if it
* found the perons in the book.
**/
public static void main(String[] args){
PhoneBook<String> bookOne = new PhoneBook<String>();
PhoneBook<Integer> bookTwo = new PhoneBook<Integer>();
bookOne.addPerson("Obama");
System.out.print(bookOne.findPerson("Obama"));
bookTwo.addPerson(192590594);
System.out.print(bookTwo.findPerson(192590594));
}
If more information from my class is needed, I can provide it. I don’t think it should be necessary because it compiled fine.
Thanks Charlie, that was it.