+ 1

How do I launch this java numbers guessing game?

I'm working on a numbers guessing game out of the head first java book and I cant get it to work. I've got 3 public classes: GameLauncher, Player and GuessGame. Only the GameLauncher class has main method in it. Are these all suppose to be in one file or should they be one inside the other or what? I know the public class usually has to be the file name as well so I assume they're supposed to be in separate files. But anytime I put them in separate files cmd says that I dont have a main method in GuessGame(which is the main syntax of the game). Not sure what to do. Surely the Head First Java book isnt wrong but you never know lol. Any help is appreciated. Thanks!

24th Oct 2019, 8:46 PM
Doug Reehill
Doug Reehill - avatar
3 Answers
+ 3
you put all of your files in the same directory and run the program that has the main method in it. im not sure how it works on sololearn
28th Oct 2019, 10:40 PM
꧁àŒș Jenspi àŒ»ê§‚
꧁àŒș Jenspi àŒ»ê§‚ - avatar
+ 3
Thank you very much Jenny, I will try that!
29th Oct 2019, 12:14 AM
Doug Reehill
Doug Reehill - avatar
0
I had the same issue. Place all 3 classes to the same file and, as there can be only one public class, keep only GameLauncher public(public class GameLauncher). then in terminal type in java [file name].java
11th Mar 2022, 5:49 PM
Vladimir Andrianov
Vladimir Andrianov - avatar