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 (Retired) Meet Objects Welcome Back

Clear not a statement

For some reason when I try to use the "clear" command just to keep up with him in this here video, I get an error message stating "not a statement".

Anyone know why this is?

3 Answers

William Li
PLUS
William Li
Courses Plus Student 26,868 Points

Remember that you have to exit the Java REPL first, then you can use the clear command to clear the screen.

you mean like ":cls"?

William Li
William Li
Courses Plus Student 26,868 Points

yeah, :cls should work within Java REPL

but if you want to use the clear command, you have to exit the JAVA REPL and back to the console in order to use it, as this clear command is available in the native Console only.

Stephen Bone
Stephen Bone
12,359 Points

So if you want to exit the java-repl use the keyboard shortcut ctrl+c or type :exit before you can compile and run the code with the commands - clear && javac file.java && java file

You can tell if you're in the java-repl as your prompt will say java> rather than just something like treehouse:~/workspace$

William Li
William Li
Courses Plus Student 26,868 Points

thanks Stephen for the detailed explanation :)

Awesome! Thank you both. Wish I could mark you both as best answer.

Justin Butler
Justin Butler
6,113 Points

But in this video 6:15. After Craig typed ':cls', the console show you treehouse:~/workspace$. It just is minor but wasa curious.

William Li
PLUS
William Li
Courses Plus Student 26,868 Points

Hi, Justin Butler , actually during the video, Craig also mentioned that, as soon as he typed :cls, the Java REPL was crashed, that's why it got sent back to the workspace command line.

Now, if you type :cls and it does what it does, clearing up the Java REPL screen instead of crashing Java REPL, that's great, because that means the Java REPL is updated to have one less crashing bug, and becomes more stable. :smiley: