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 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?