Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9220229
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T03:17:57+00:00 2026-06-18T03:17:57+00:00

I am trying to run my linked list in a main method, but for

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T03:17:58+00:00Added an answer on June 18, 2026 at 3:17 am

    After compiling with javac PhoneBook.java are you launching it using
    java PhoneBook or java PhoneBook.java ? (it should be the former not
    the latter). ~Charlie

    Thanks Charlie, that was it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to sort names into alphabetical order inside a linked list but am
I am trying to implement a linked tree but I am getting a nullpointer
Trying to run a simple svn list svn+ssh://... from within jenkins on os X,
I am trying run a program from a qmake .pro file which modifies the
Trying to run the following command in php to run powershell command... the following
Trying to run my program in FreeBSD OS, I have the following results: $
Trying to run Jison unit tests, but the command fails. How do I fix
When trying to run a junit test I get the following error - java.lang.ClassCastException:
Following is my implementation of queue using linked list.I am totally new to data
I have been trying to implement my own linked list class for didactic purposes.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.