解决方案 »

  1.   

    控制台是操作系统提供的,System.console()也会得到这个控制台
    java.exe是win32控制台应用,javaw.exe是一个win32的GUI应用,这是它们的根本区别
      

  2.   

    控制台就是命令行界面,win下是cmd.exe
      

  3.   

    感觉楼主可以这样来理解区别:
    1、java启动的程序是命令行程序或阻塞程序,如果该程序未执行完毕或未被关闭,则所打开的命令行将被阻塞,不能执行其它命令如dir等,可以通过Ctrl+C等方式关闭程序;
    2、javaw启动的程序是窗口程序或非阻塞程序,在使用该命令运行程序后,可接着在命令行中执行下一命令,且启动的程序与命令行无关不依赖命令行,不能通过Ctrl+C关闭。
      

  4.   

     恩 线程阻塞的这个区别之前看到了,大牛能否解释下 
    String str=System.console().readLine();
    在java 和 javaw 里面执行时获取控制台的情况  
      

  5.   

    5楼的意思很清楚了。System.console()在javaw.exe(Eclipse中运行) 返回的是一个空对象。在java.exe(DOS下运行) 返回的是一个实例。楼主,java控制台输入还是用Scanner类吧!
      

  6.   

    两个功能完全一样,除了:javaw是没有关联的控制台
      

  7.   


    简单点说就是在javaw.exe中无法获取Console Methods to access the character-based console device, if any, associated with the current Java virtual machine.Whether a virtual machine has a console is dependent upon the underlying platform and also upon the manner in which the virtual machine is invoked. If the virtual machine is started from an interactive command line without redirecting the standard input and output streams then its console will exist and will typically be connected to the keyboard and display from which the virtual machine was launched. If the virtual machine is started automatically, for example by a background job scheduler, then it will typically not have a console.If this virtual machine has a console then it is represented by a unique instance of this class which can be obtained by invoking the System.console() method. If no console device is available then an invocation of that method will return null. 
      

  8.   

    有点忙,不好意思。这个console对象是从JDK1.6中引入的,我搞好几年java在项目中没用到过Console,抱歉啊。楼主了解一个新东西,可像版主那样,从基本的JDK提供的API文档看起,里面也提供了示例,尝试着用一下所提供的方法,再跟现有技术对比。从Console的API来看,也就是读取输入,楼主把它跟Scanner作下对比搞篇文章加深印象,还希望到时分享一下哦。