控制台输入错误java.lang.NullPointerException

Ent*_*tic 7 java io

我试过代码:

import java.io.Console;
public class Default
{
    public static void main(String args[]) throws IOException
    {
        Console console = System.console();
        String testing = console.readLine("Enter Name: ");
        System.out.println("Entered Name: "+ testing);
    }
}
Run Code Online (Sandbox Code Playgroud)

转到异常,出现以下错误:
Source not found. NullPointerException

我正在使用Eclipse Juno EE进行调试..!

以上编写的代码的参考链接在这里

Ala*_*ava 5

从IDE中使用时,您是否从想法上运行程序作为console.readLine收益null

有关更多详细信息,请参阅此

如果从命令行运行它,则不会收到此错误。