Can't read console for simple GUI, I'm using: import java.io.Console


#1

// here's the code, I want to be able to say what my name is, and then it will say "Hi, Chris!"

package tutorial;

import java.io.Console;

public class Tut {

	public static void main(String[] args) {
		System.out.println("Hello Tutorial!!!");
		Console hi = System.console();
		System.out.println("What's your name?");
		String sup = hi.readLine();
		
		if (sup.length() > 1) {
		System.out.println("HI, " + sup + " .");
		}

	}
	
}

// If you could point me in the right direction that would be awesome!


#2

Um, you can use like another code editor or best for java Eclipse you cant do this on codecademy unfourtunately


#3

i am using eclipse:


#4

Its a null pointer exeption. You can either search about that, or best if you ask that in

Stack Overflow

stackoverflow.com


#5

if you are bent on using the Console class then read on a solution HERE. As far as I have read, using a console object in an IDE(which provides an abstraction layer) will always give null.

Possible Solution for achieving I/O interaction with user is via the SCANNER CLASS or the
BUFFEREDREADER and INPUTSTREAMREADER classes


#6

Thanks guys, and happy holidays!