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 Basics Getting Started with Java Strings, Variables, and Formatting

Jan Lundeen
Jan Lundeen
5,886 Points

Corrected quotes on Challenge Task 2 of 3 for Java Basics, strings and variables. Still getting compiler errors

Hi,

I corrected my quotes, but I'm still receiving compiler errors: Here's my code: String firstName = "Jan"; console printf ("Jan can code java!/n"); javac Name.java java Name

I'm not sure why I'm still seeing compiler errors. Any ideas?

Thanks,

Jan

Name.java
String firstName = "Jan";
console printf ("Jan can code Java!/n")
  javac Name.java
  java Name
  // I have setup a java.io.Console object for you named console

7 Answers

Steven Parker
Steven Parker
231,248 Points

It looks like there's a few issues:

  • the 2nd line is missing a semicolon at the end
  • there should be a membership operator (".") between "console" and "printf"
  • for task 2, the challenge wants you to literally put "<YOUR NAME> can code in Java!" as the message
  • you don't need a newline after the message (and a newline is "\n" instead of "/n")
  • the third and fourth lines are compile and run commands and should not be in the source file.
Jan Lundeen
Jan Lundeen
5,886 Points

Hi Steven,

Your right. Gosh, I missed that the 2nd line is missing a semicolon. Thanks for the catch! Guess I've been staring at my code too long. :)

So I don't need the compile and run commands?

Thanks.

Jan

Steven Parker
Steven Parker
231,248 Points

You use the commands in the command window when working in the Workspace, but you don't put them in the code file.
For a challenge you don't need them, it does the compiling for you.

Jan Lundeen
Jan Lundeen
5,886 Points

I only see one window. It sounds like the command window is separate from the window where I enter my code. Where is the command window?

Thanks,

Jan

Steven Parker
Steven Parker
231,248 Points

Maybe "Console pane" is a better term, but that's only for the Workspace.

Jan Lundeen
Jan Lundeen
5,886 Points

I don't see a separate tab on the code editor window, just the name of the file(Name.java). Where is the "View" menu for "Show Console". I tried to make a screenshot of what I'm seeing (using Alt-PrintScreen), but I can't paste it (using Control-V) to my answer.

Jan Lundeen
Jan Lundeen
5,886 Points

After I added my code [e.g. String firstName = "Jan"; console printf ("Jan can code Java!/n"); ], I followed my code with the commands javac Name.java and Java Name. Then, I clicked the "Check Work" button. When I started the challenge, I noticed the comment below:

// I have setup a java.io.Console object for you named console

So I thought that I didn't have to do any other setup. I also looked at my workspace, but I think that's something separate from this. However, I did notice separate tabs (including one titled "View").

I looked at the comments in the String and Variables section from other students. It seems like there were lots of issues with Workspaces, but nothing that would answer the issue I'm experiencing.

Thanks,

Jan

Steven Parker
Steven Parker
231,248 Points

I accidentally confused things with workspace references, they don't apply to the challenge.
I revised my original answer with a more complete issues list, see if that helps.

Jan Lundeen
Jan Lundeen
5,886 Points

No worries. I didn't know that's what they were asking for. That worked. Thanks!

Jan

Jan Lundeen
Jan Lundeen
5,886 Points

Sorry about that. i corrected the Best Answer. Not sure what happened.