Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java Local Development Environments Exploring Your IDE Running Your Code

Sean Flanagan
Sean Flanagan
33,235 Points

How do I run this?

Hi.

I used Alt Shift F10 to run the program but I got this little dialogue box called Run with one option: Edit Configurations. What should I do next please? Thanks.

Sean

8 Answers

Seth Kroger
Seth Kroger
56,413 Points

It sounds like you don't have a build configuration set so click the green plus sign in the upper left to add one, and select Application from the drop down. Make sure the "Main class" option is set to the class with the main() method you want to run.

Sean Flanagan
Sean Flanagan
33,235 Points

Hi Seth.

As far as the video is concerned, I've watched up to 1 minute 36 seconds. I got as far as the "Run - Unnamed" dialogue box.

Here's my Karaoke.java syntax:

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();
    songBook.importFrom("songs.txt");
    KaraokeMachine machine = new KaraokeMachine(songBook);
    machine.run();
    System.out.println("Saving book....");
    songBook.exportTo("songs.txt");
  }
}

Here are the results I got from running Karaoke.java (if that's the correct file):

Exception in thread "main" java.lang.ClassNotFoundException: Karaoke
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:264)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:122)

Process finished with exit code 1

Am I doing this right so far?

Thanks. :-)

Craig Dennis
STAFF
Craig Dennis
Treehouse Teacher

Hey Sean!

The template we used originally set up a configuration, but we need to make one for this imported project. In the video I do that at about 1:46

Karaoke.java file in the package com.teamtreehouse on the left? Sounds like maybe it isn't. If not, maybe try re-watch the importing video.

Keep me posted.

Sean Flanagan
Sean Flanagan
33,235 Points

Hi Craig. Sorry for the delay due to a very busy week.

You're right, Karaoke.java isn't on the left. When you say "Importing" do you mean "Importing External Code"?

Thanks.

Sean

Sean Flanagan
Sean Flanagan
33,235 Points

I'm watching the Importing video now. I noticed that in my song.java, I'd missed out the word "model" at the end of the import statement. Also, the line under @Override runs off the right of the screen so I don't know what's missing.

My song.java:

package com.teamtreehouse.model;

public class Song {
  protected String mArtist;
  protected String mTitle;
  protected String mVideoUrl;

  public Song(String artist, String title, String videoUrl) {
    mArtist = artist;
    mTitle = title;
    mVideoUrl = videoUrl;
  }

  public String getTitle() {
    return mTitle;
  }

  public String getArtist() {
    return mArtist;
  }

  public String getVideoUrl() {
    return mVideoUrl;
  }


  @Override
  public String toString() {
    return String.format("Song:  %s by %s", mTitle, mArtist, mVideoUrl);
  }
}
Craig Dennis
STAFF
Craig Dennis
Treehouse Teacher

Hey Sean,

I'd start over and just follow the video if I were you. Copy the com folder by dragging and then copy the Karaoke.java file by dragging. You aren't meant to need to edit the files, and if you are, I think something is wrong.

Let me know how the restart goes! It should just work ;)

Sean Flanagan
Sean Flanagan
33,235 Points

Hi Craig. Thanks for getting back to me. The com.teamtreehouse folder is in the left pane inside the src folder.

Craig Dennis
Craig Dennis
Treehouse Teacher

And just drag Karaoke.java to the root of the src folder.

Sean Flanagan
Sean Flanagan
33,235 Points

I've dragged Karaoke.java to src.

Craig Dennis
Craig Dennis
Treehouse Teacher

Did running it like I did in the video work now?

Sean Flanagan
Sean Flanagan
33,235 Points

I ran it but it brought up my SongBook.java.

Craig Dennis
STAFF
Craig Dennis
Treehouse Teacher

Make sure you are in your Karaoke.java file when you choose Run...and choose Run > Run...

It will ask for configurations...I guess you have SongBook.java as Run Configuration. We go over that in a bit.

Hope it helps!

Sean Flanagan
Sean Flanagan
33,235 Points

Yes I do have SongBook.java as Run Configuration. When I ran Karaoke.java, I got this:

Information:Using javac 1.8.0_60 to compile java sources
Information:java: Errors occurred while compiling module 'Karaoke'
Information:23/09/2015 00:19 - Compilation completed with 14 errors and 0 warnings in 4s 11ms
C:\Users\user\IdeaProjects\Karaoke\src\com\teamtreehouse\SongBook.java
Error:(13, 18) java: cannot find symbol
  symbol:   class Song
  location: class com.teamtreehouse.SongBook
Error:(53, 25) java: cannot find symbol
  symbol:   class Song
  location: class com.teamtreehouse.SongBook
Error:(62, 30) java: cannot find symbol
  symbol:   class Song
  location: class com.teamtreehouse.SongBook
Error:(79, 17) java: cannot find symbol
  symbol:   class Song
  location: class com.teamtreehouse.SongBook
Error:(16, 32) java: cannot find symbol
  symbol:   class Song
  location: class com.teamtreehouse.SongBook
Error:(24, 18) java: cannot find symbol
  symbol:   class Song
  location: class com.teamtreehouse.SongBook
Error:(45, 29) java: cannot find symbol
  symbol:   class Song
  location: class com.teamtreehouse.SongBook
Error:(63, 26) java: cannot find symbol
  symbol:   class Song
  location: class com.teamtreehouse.SongBook
Error:(64, 14) java: cannot find symbol
  symbol:   class Song
  location: class com.teamtreehouse.SongBook
Error:(65, 18) java: cannot find symbol
  symbol:   class Song
  location: class com.teamtreehouse.SongBook
Error:(80, 14) java: cannot find symbol
  symbol:   class Song
  location: class com.teamtreehouse.SongBook
Error:(81, 35) java: cannot find symbol
  symbol:   class Song
  location: class com.teamtreehouse.SongBook
Error:(84, 32) java: cannot find symbol
  symbol: class Song
Error:(84, 44) java: cannot find symbol
  symbol: class Song
Craig Dennis
Craig Dennis
Treehouse Teacher

Sean can you just delete the project and start over? This is a new bug that I assume got introduced by moving things around.

It just works when you copy things correctly. I feel like you are spending way too much time here trying to fix this, and I'm sorry about that.

Let's just start over, should not be difficult at all.

Fingers crossed it goes better next time!