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 Java Objects Creating the MVP Storing Guesses

edumorlom
edumorlom
4,073 Points

I am getting an error on jshell when I run: Game game = new Game("treehouse"); The code is exactly the same.

For some reason, Game.class is not being generated. Only Hangman.class is being generated. Could that be the issue? How can Game.class be generated? They are all in the same folder.

jshell> /open Game.java

jshell> Game game = new Game("treehouse");
| Error:
| cannot find symbol
| symbol: class Game
| Game game = new Game("treehouse");
| ^--^
| Error:
| cannot find symbol
| symbol: class Game
| Game game = new Game("treehouse");
| ^--^

edumorlom
edumorlom
4,073 Points

Sorry, I am new to TeamTreeHouse. https://w.trhou.se/a3hd92p6oe

2 Answers

Hey Eduardo!

The reason why your Game.java class is not being compiled in because you are not using it in your Hangman.java file. If you go back to the Getting Started, when Craig compiles Hangman.java he says, "It will at least compile Game.java and not Prompter.java since we haven't created an instance of it, yet."

I will say this again, the reason why your Game.java ins't being compiled is because you are not instantiating(or creating a variable with the object type "Game") the Game.java class in the Hangman.java.

At the moment, your Hangman.java looks like this:

public class Hangman {

  public static void main(String[] args) {
    // Your incredible code goes here...

  }
}

It should look like this:

public class Hangman {

  public static void main(String[] args) {
    // Your incredible code goes here...
       Game game = new Game("treehouse");
  }
}

Once you instantiate the Game.java class, the compiler should compile the Game class.

Hope I was of some help! And don't get frightened if you don't understand how and why things are happening the way they are, right now. By the time you are done with this track, you will find this course very easy. Just "Hang" in there ;)

Brendan Whiting
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Brendan Whiting
Front End Web Development Techdegree Graduate 84,738 Points

This is what your Hangman.java looks like on my end:

public class Hangman {

  public static void main(String[] args) {
    // Your incredible code goes here...

  }
}

I think the issue is that you need to save the file and recompile. Is there a little orange circle next to the file name?