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 and Variables

eddie Torres
eddie Torres
444 Points

Terminal not showing printf command result

I'm not getting the same result as the video, the terminal just runs the code without errors but not displaying the printf code.

11 Answers

Oh okay, thanks for the screenshot. It seems that your code is not saved. Try saving it and run it again :)

Kind of funny considering the instructor also forgot to save in one of the videos. I guess you were just following instruction *too well. :)

Hello eddie,

Could you post your java code? Were there any errors when you compiled the code?

-Agapito

eddie Torres
eddie Torres
444 Points

Hello, there were no errors when the code was compiled. Here is the java 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("Hello, my name is sis");
      console.printf("Craig is learning how to write java");
  }
}

Hi eddie, I formatted your code using markdown so it can be more readable. You can check Posting code in the forum to find out how I did it.

Hello eddie,

It looks like you have an extra } at the end of your code. Could you remove it, recompile and run it again?

-Agapito

EDIT: Never mind.

The formatting was off in the code. Here it is cleared up:

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 sis");
  console.printf("Craig is learning how to write java");
} }

Eddie,

Try moving the final closing brace, }, onto a line by itself, and see if that helps.

-Agapito

eddie Torres
eddie Torres
444 Points

Thanks Gloria. Agapito, I've tried that it gives the same result. I use Chrome, weird.

The problem is not the code. Your code is correct. There are 2 steps involved.

1. Compile the code using:

javac Introductions.java

2. Run the code using:

java Introductions

that should work :)

eddie Torres
eddie Torres
444 Points

Gloria that's exactly what I typed, I tried several times. But the terminal runs the code and compiles it without errors.

java and javac?

eddie Torres
eddie Torres
444 Points

Thanks that was my problem.

You are welcome Eddie.