Unable to read data from Java Console class. (I'm using Eclipse to run it!!)

30 Views Asked by At

I'm unable to run this code correctly.. Please help me out

public static void main(String[] args){     
     Console console = System.console();    // unable to fetch anything. It returns null
    if (console == null) {
        System.out.println("Unable to fetch console");
        return;
    }
    System.out.println("Enter your name: ");   //compiler doesn't come till here 
    String n=console.readLine();    
    System.out.println("Welcome "+n);   
}
0

There are 0 best solutions below