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
Hussain Shaikh
404 PointsJava TreeStory Error
I keep getting an error : TreeStory.java:22: error: reached error at end of file while parsing console.printf("They are always %s %s.\n", adverb, verb);
![The alternate text]https://teamtreehouse.com/workspaces/7147612
14 Answers
Jeremiah Montano
7,221 PointsGood evening,
The error message you are receiving, "reached error at the end of file while parsing," is generated if a curly bracket is missing at the end of the code. Make sure you have a closing bracket for both your class and your method. If there is no ending curly bracket, the compiler will throw this error. See the code below:
import java.io.Console;
public class TreeStory {
public static void main(String[] args) {
Console console = System.console();
/* Some terms:
noun - Person, place or thing
verb - An action
adjective - A description used to modify or describe a noun
Enter your amazing code here!
*/
// __Name__ is a __adjective__ __noun__. They are always __adverb__ __verb__.
String name = console.readLine("Enter a name: ");
String adjective = console.readLine("Enter an adjective: ");
String noun = console.readLine("Enter a noun: ");
String adverb = console.readLine("Enter an adverb: ");
String verb = console.readLine("Enter a verb ending with -ing: ");
console.printf("Your TreeStory:/n------------\n");
console.printf("%s is a %s %s. ", name, adjective, noun);
console.printf("They are always %s %s.\n", adverb, verb);
} //Closing bracket for public static void main(String[] args) line
} //Closing bracket for public class TreeStory line.
The nice thing about the workspaces is when your cursor is next to a closing curly bracket, it will show you which opening bracket it relates to. Try it out!
I hope this message finds you well. Happy coding!
Peter Price
4,007 PointsHi Hussain,
I tried to access your workspace, but my browser said that the web page couldn't be found.
If you could post your code I may be able to help.
Peter Price
4,007 PointsHave you closed the curly brackets, }, underneath the last line?
Hussain Shaikh
404 PointsI don't remember if the instructor used curly brackets for this exercise?
Peter Price
4,007 PointsCould you try it?
Is the instructor Mr. Craig?
Peter Price
4,007 PointsDid you put it on the next line down? That may make a difference.
Peter Price
4,007 PointsHi Hussain,
Me again! I was just wondering if Jeremiah's answer has solved the problem, if it has you should click on the "Best Answer" button underneath his post and then I will know that you have solved the problem.
Thanks for your input Jeremiah! :)
Hussain Shaikh
404 PointsOh sorry Peter. Thanks for the help! You and Jeremiah have been great. Much appreciated!
Hussain Shaikh
404 PointsHi Peter,
I'll check it out now and get back to you very shortly.
Thanks!!
Hussain Shaikh
404 Pointsconsole.printf("Your TreeStory:/n------------\n"); console.printf("%s is a %s %s. ", name, adjective, noun); console.printf("They are always %s %s.\n", adverb, verb);
I keep getting an error on the last code when I try to run it.
Peter Price
4,007 PointsI can't see any errors.
Would it be too hard to post all of your code in your project?
Hussain Shaikh
404 Pointsimport java.io.Console;
public class TreeStory {
public static void main(String[] args) {
Console console = System.console();
/* Some terms:
noun - Person, place or thing
verb - An action
adjective - A description used to modify or describe a noun
Enter your amazing code here!
*/
// __Name__ is a __adjective__ __noun__. They are always __adverb__ __verb__.
String name = console.readLine("Enter a name: "); String adjective = console.readLine("Enter an adjective: "); String noun = console.readLine("Enter a noun: "); String adverb = console.readLine("Enter an adverb: "); String verb = console.readLine("Enter a verb ending with -ing: ");
console.printf("Your TreeStory:/n------------\n"); console.printf("%s is a %s %s. ", name, adjective, noun); console.printf("They are always %s %s.\n", adverb, verb);
Then I run it (by clicking Enter) and get this message: TreeStory.java:22: error: reached error at end of file while parsing console.printf("They are always %s %s.\n", adverb, verb);
The error message points above the last parenthesis. I hope this helps.
Hussain Shaikh
404 Points// Name is a adjective noun. They are always adverb verb. String name = console.readLine("Enter a name: "); String adjective = console.readLine("Enter an adjective: "); String noun = console.readLine("Enter a noun: "); String adverb = console.readLine("Enter an adverb: "); String verb = console.readLine("Enter a verb ending with -ing: ");
console.printf("Your TreeStory:/n------------\n");
console.printf("%s is a %s %s. ", name, adjective, noun);
console.printf("They are always %s %s.\n", adverb, verb);
Hussain Shaikh
404 PointsSure I'll try it. Yes, Mr. Craig Dennis. I also launched a brand new workspace for that particular exercise and the ran it. I received the same error message.
Hussain Shaikh
404 PointsSo I just closed a curly bracket ( } ) after the.........verb);
I received the same error message. I completed the working prototype stage regardless but was having trouble with this particular task.
Hussain Shaikh
404 PointsI did just that. No luck https://teamtreehouse.com/workspaces/7147612
I don't know what it could be. I launched a brand new workspace for that particular exercise and the ran it. I received the same error message.
Peter Price
4,007 PointsI think only you can access your own workspace links.
I had another look at your error code and it indicates that the problem is on line 22.
If you have received any emails from Mr. Craig you could email back to him with the code. He may be able to help.
I am following the discussion so if you have any more information you could post it and I would see it (as well as anyone else). If I get any more info I will let you know. I am not stopping, I just don't have any more ideas at the moment, as I said if I get any more info I will let you know. (I will still be working on my projects on treehouse, so I will get a notification if you post anything)
Hussain Shaikh
404 PointsI have the browser open. Does that not let you get in?
Peter Price
4,007 PointsNo it doesn't.
Hussain Shaikh
404 PointsOK sounds good. I moved onto the next Stage, launched a new workspace and tried to run the new code and that same error keeps coming up. I inserted the same info Mr. Dennis did into my workspace, I don't get it?
Thanks for all the help!
Peter Price
4,007 PointsNo Problem, I'll still be around.
Hussain Shaikh
404 PointsHussain Shaikh
404 PointsHi Jeremiah,
Do you exactly where I'm supposed to place the curly bracket (s) in the Workspace? I tried to insert a curly bracket at the end of my code at the.....verb); but no luck. I guess I don't exactly know where to place them. I checked the Mr. Dennis' workspace and didn't see a closing bracket.
Thanks for the help!
Jeremiah Montano
7,221 PointsJeremiah Montano
7,221 PointsHi Hussain,
The curly brackets go at the end of your code for that particular method/class. Coding etiquette states they should be on separate lines by themselves, but as long as you have enough curly brackets to close out your code you will be fine. Each time you open a bracket, you must have a closing on at the end of it. I hope the below code helps in determining when/where/why you need the ending curly brackets.
Hussain Shaikh
404 PointsHussain Shaikh
404 PointsThanks a lot Mr. Montano!