Search code examples
javaeclipseconsoleuser-inputjava-6

Java console from eclipse


I am trying to implement the Java 6 console api. If I am trying to run my java class as Java Application why is my console null? Or shall I be running my .java from command promt like c:workspace>java -cp . console

My console.java class

    public class console{
    public static void main(String s[])throws IOException
    {
    Console c=System.console();
    if(c==null)     
    {
     System.err.println("Console object is not available");
    }
    else{
     String name = null;
     name = c.readLine("Enter any String: ");
   ...}

Solution

  • Please see this bug. Seems like you'd need to use the command line.