GeeCON Prague 2014*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Problems to use Console object on Java 6 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Problems to use Console object on Java 6" Watch "Problems to use Console object on Java 6" New topic
Author

Problems to use Console object on Java 6

Carlos Renato Domingos da Silva
Greenhorn

Joined: Dec 03, 2011
Posts: 4
Hi , I am using jdk1.6.0_27 and I am with problems on Console Object.

I am also using eclipse Helios Service Release 1 ( 20100917-0705 ).

This code below prints null. Somebody knows why?




import java.io.Console;

public class ConsoleTest {

public static void main(String[] args) {

Console console = System.console();

System.out.println("Console is " + console);

}
}



This code prints in my console: "Console is null"

What 's the problem?


Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3606
    
  15
Carlos Renato Domingos da Silva wrote:What 's the problem?

Eclipse is the problem


Joanne
Jeffrey Tian
Ranch Hand

Joined: Jun 02, 2010
Posts: 34
If you run it in command line, you'll get what you want.
 
GeeCON Prague 2014
 
subject: Problems to use Console object on Java 6