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 trialNika Zurashvili
305 PointsWhat is the reason behind this error when compiling a Java code via the console?
Hi,
As you might have already guessed, I'm very new to coding and Java, so I'm following Craig Dennis' tutorials.
I'm currently on the second video "Strings and Variables" and when I try to compile my work via the console I get this error:
"
Picked up JAVA_TOOL_OPTIONS: -Xmx128m
Picked up _JAVA_OPTIONS: -Xmx128m
Introductions.java:10: error: reached end of file while parsing
}
^
1 error
"
Can you guys help me with this? It's holding me back from progressing further into the course. Thanks!
12 Answers
Juraj Sallai
7,188 PointsProbably just missing { or }. It happens when you dont properly close the class.
Nika Zurashvili
305 PointsNo, actually. The code is so simple, it'd be too hard to miss a mistake.
" import java.io.Console;
public class Introductions {
public static void main(String[] args) {
Console console = System.console();
// Welcome to the Introductions program! Your code goes below here
console.printf("Hello, my name is Nika");
console.printf("Nika is learning how to write Java");
} "
Do you think I've forgotten to end a code or something?
This is what the console outputs if I try to compile (using the following: javac Introductions.java) the code above:
"
treehouse:~/workspace$ javac Introductions.java <--- This is how I try to compile the code.
Picked up JAVA_TOOL_OPTIONS: -Xmx128m
Picked up _JAVA_OPTIONS: -Xmx128m
Introductions.java:10: error: reached end of file while parsing
}
^
1 error
"
Juraj Sallai
7,188 PointsYes it seems you are missing } at the end of your code. You need to close class and also main method.
Nika Zurashvili
305 PointsOkay! So, I edited the code and put a "}" at the end.
This is what it looks like now:
" import java.io.Console;
public class Introductions {
public static void main(String[] args) {
Console console = System.console();
// Welcome to the Introductions program! Your code goes below here
console.printf("Hello, my name is Nika");
console.printf("Nika is learning how to write Java");
}
} "
But still, the same error is displayed when compiling the code.
Here it is:
"
treehouse:~/workspace$ javac Introductions.java
Picked up JAVA_TOOL_OPTIONS: -Xmx128m
Picked up _JAVA_OPTIONS: -Xmx128m
Introductions.java:10: error: reached end of file while parsing
}
^
1 error
"
Need help.
Juraj Sallai
7,188 PointsAre you sure you saved changes in Workspace?
Nika Zurashvili
305 PointsYes, certainly.
Juraj Sallai
7,188 PointsStrange, I am nôt getting that error...
import java.io.Console;
public class Introductions {
public static void main(String[] args) {
Console console = System.console();
// Welcome to the Introductions program! Your code goes below here
console.printf("Hello, my name is Nika");
console.printf("Nika is learning how to write Java");
}
}
Nika Zurashvili
305 PointsGosh... What should I do? I messaged the staff, so hopefully they can help me out.
Craig Dennis
Treehouse TeacherHi Nika Zurashvili !
Can you create a workspace snapshot for me please? At the top of the workspace window there is a camera. It will create a link that will let me see your workspace.
Thanks!
Craig Dennis
Treehouse TeacherHere's the output as I got it. Are you seeing something different?
treehouse:~/workspace$ javac Introductions.java
Picked up JAVA_TOOL_OPTIONS: -Xmx128m
Picked up _JAVA_OPTIONS: -Xmx128m
treehouse:~/workspace$ java Introductions
Picked up JAVA_TOOL_OPTIONS: -Xmx128m
Picked up _JAVA_OPTIONS: -Xmx128m
Hello, my name is NikaNika is learning how to write Java
Nika Zurashvili
305 PointsThing is that I’m seeing the Xmx messages but not the ‘Nika is learing’ message.
Craig Dennis
Treehouse TeacherAre you sure? The prompt is showing up after that line......you are missing the new lines so it's all on one line.
Craig Dennis
Treehouse TeacherAnd you've written javac Introductions.java
to compile and then java Introductions
to run?
Nika Zurashvili
305 PointsOh gosh! No, that’s what I forgot to do! I forgot to run it after compiling. Thanks Craig!
Craig Dennis
Treehouse TeacherCommon mistake! Glad we tracked it down!
Stick with it! ??
Nika Zurashvili
305 PointsThanks Craig and I will! By the way, you’re tutorials are really easy to understand! Good job and thanks, never thought I’d even manage to write a single line of code, lol
Nika Zurashvili
305 PointsYeap! I don’t get that message in the console. Feels kind of discouraging. Already wasted 2 days of my trial because of this :/
Nika Zurashvili
305 PointsCraig Dennis , I was able to progress further into the course but I still get those Xmx messages before what I actually want to get in the console. Is this normal? Am I doing something wrong? Because I don't see similar thing happening to you in those tutorials.