Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Java Java Data Structures Efficiency! Menu UI

Kiefer Levine
Kiefer Levine
6,184 Points

Console says "Error: Could not find or load main class Karaoke" when I enter "java Karaoke" after compile.

Title pretty much says it. I can compile Karaoke.java without error, but attempting to run it results in the message "Error: Could not find or load main class Karaoke."

I've fiddled with where the Karaoke folder sits. I've moved it to the "model" folder, the "teamtreehouse" folder and right next to "com" itself (which I believe is in a "Java Data Structures - Map Out the MVP" folder, though I can't hide/reveal its contents as I can the folders within it).

So uh... halp pleez.

2 Answers

Shezan Kazi
Shezan Kazi
10,807 Points

Oh I got it now. Please delete the first line from your Karaoke.java i.e. package com.teamtreehouse;

That should do the trick

Kiefer Levine
Kiefer Levine
6,184 Points

That did it! Thanks! So you don't import packages in the main class, then? Good to know.

Dylan Carter
Dylan Carter
4,780 Points

if anyone could comment as to WHY we don't add the user interface class into the rest of the package I would appreciate it. Still confused as to why we don't.

Shezan Kazi
Shezan Kazi
10,807 Points

Hi,

can you please post a link to your workspace or your code?

Thanks, Shezan

Kiefer Levine
Kiefer Levine
6,184 Points

Link to snapshot of workspace: https://w.trhou.se/4do5u29b62. And here's just Karaoke, the troublesome one:

package com.teamtreehouse;

import com.teamtreehouse.KaraokeMachine;
import com.teamtreehouse.model.Song;
import com.teamtreehouse.model.SongBook;

public class Karaoke {

  public static void main(String[] args) {
    SongBook songBook = new SongBook();
    KaraokeMachine machine = new KaraokeMachine (songBook);
    machine.run();
  }
}

Lemme know if you need me to post other files.