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 trialHemmings Koranteng
2,568 Pointsconsole is freezing?! or maybe i'm coding badly?!
Hi All,
im currently following along the course in the workspace for (java path, learning objects, creating mvp section).
up until now i have been compiling & running the code in the workspace with no problems, but after the "remaining tries" video i cannot seem to execute the code in the console.
there are no runtime error messages and the console just seems to hang and shows the following:
"picked up JAVA_TOOL_OPTION: Xmx128m Picked up JAVA_OPTIONS: -Xmx128m JAVA_TOOL_OPTION: Xmx128m Picked up _JAVAOPTIONS: -Xmx128m"
I thought it may be server overload or something but i've come back the next morning to find the same issue. also i am able to type below the above mentioned and this is not the behaviour i expected.
i'm running the code using the following command -
clear && javac Hangman.java && java Hangman.
if i miss spell any of the above i get the "Error: could not find or load main class Hangma"
i have eyeballed the code to compare against the craig's and cant seem to find any errors. i may have missed something but without any error messages its difficult to tell.
my code can be found here - https://w.trhou.se/dxva82it7t! Please can you let me know what i'm doing wrong as i would like to continue following on with the course.
Thanks
1 Answer
andren
28,558 PointsYour code gets stuck in an infinite loop due to the semicolon in this line:
while (game.getRemainingTries () > 0); {
You are not meant to use semicolons after the parenthesis of while
statements (or if/else if
statements for that matter) since it tells Java that you are done defining the loop, when in reality you have not actually provided the loop with code to run yet.
If you simply remove the semicolon like this:
while (game.getRemainingTries () > 0) {
Then that should solve your current problem.
Steve Hunter
57,712 PointsGood spot!
Hemmings Koranteng
2,568 PointsThanks gents!
i must have missed that, I'll be more accurate going forward
much appreciated
Steve Hunter
57,712 PointsSteve Hunter
57,712 PointsI've forked your workspace and get the same issue. You have a recursion somewhere, i.e. a constant loop that won't exit. I'll look further now.