Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Java Java Basics Getting Started with Java Introduction to Your Tools

Andrew Minert
Andrew Minert
3,984 Points

printf not working. Everything looks good until I try and run the code.

I have this in my code

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("My name is Andrew");
  }
}

and then I type this in my console

treehouse:~/workspace$ javac Introductions.java                                                                                                                          
Picked up JAVA_TOOL_OPTIONS: -Xmx128m                                                                                                                                    
Picked up _JAVA_OPTIONS: -Xmx128m                                                                                                                                        
treehouse:~/workspace$ ls                                                                                                                                                
Introductions.class  Introductions.java                                                                                                                                  
treehouse:~/workspace$ java Introductions                                                                                                                                
Picked up JAVA_TOOL_OPTIONS: -Xmx128m                                                                                                                                    
Picked up _JAVA_OPTIONS: -Xmx128m                                                                                                                                        
treehouse:~/workspace$             

Why is it not printing My name is Andrew into the console?

3 Answers

Denis Madroane
Denis Madroane
2,983 Points

Did you hit Save before you compiled? I remember this happening to me when I first went through that course. Go to File>Save All and then try to compile again.

Andrew Minert
Andrew Minert
3,984 Points

Thank you! That was exactly what I did wrong

Mykhaylo Stolyarchuk
PLUS
Mykhaylo Stolyarchuk
Courses Plus Student 94 Points

Before compiling you have to make sure that the code is saved. Then you need to compile with javac, afterwards with java you can compile console.printf

I'm having that issue myself right now, but I've tried both of these answers and neither has helped me

Did you make sure that console.printf is all lowercase?