[ tep3a @ 04.11.2007. 19:42 ] @
daklem,

ovaj kod:

Code:

package info.terza.sistemski;

import java.io.Console;

public class ConsoleTest {

    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        try {
            Console con = System.console();
            if (con == null) {
                System.out.println("Nema konzole??");
            }
            
            String unos = con.readLine("Unesite neku rec: ");
            System.out.println("Sa konzole je uneseno: "+ unos);
            
            
        } catch (Exception e) {
            // TODO: handle exception
        }
        
    }

}



baca exception i ispise "Nema konzole??" bilo pod Eclipse-tom ili IntelliJidea.

Verzija Jave je 1.6.0 u3 i kada ovaj kod kompajliram i poteram iz konzole, radi sasvim ok!

U cemu je fora? Da li postoji nacin da podesim ova okruzenja da imam punu konzolu u njima?

Unapred hvala!
[ bags @ 04.11.2007. 23:23 ] @
Koristi umejsto Console: new Scanner( System.in ) .

Objasnjenje sa http://java.sun.com/javase/6/docs/api/java/io/Console.html :

Citat:

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.