简体   繁体   中英

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 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: ");
   ...}

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM