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

Can't get either Hangman or Forum to work in BlueJ or compiling with javac(cmd)

They work fine within this site's compiler but I can't get any of the examples to compile within windows or blueJ. Am I missing something?

2 Answers

The site's workspaces do something special with Console. I am not sure exactly what .

Console console = System.console();
// won't work on an IDE.

If you are using BlueJ or another IDE then you will need to use BufferedReader and InputStreamReader:

import java.io.BufferedReader;
import java.io.InputStreamReader;

class Example {
    public static void main (String[] args) {
        BufferedReader myReader = new BufferedReader(new InputStreamReader(System.in));
        String myInput = "";

        System.out.printf("Enter some input: %n");
        myInput = myReader.readLine();
        System.out.printf("The input was: %s %n", myInput);

    }
}

Oh.. Maybe I need to import Console? Never thought of that..