Forum » Programiranje » Console class [Java]
Console class [Java]
Bojevnik ::
Pri spomnji metodi je conzola ki jo ustvarim zmeraj null, kaj je narobe?
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package javaapplication1; /** * * @author Bojevnik */ import java.io.Console; public class Main { /** * @param args the command line arguments */ public static void main(String[] args) { Console con=System.console(); if (con==null) System.out.println("sss"); // TODO code application logic here } }
- spremenilo: Bojevnik ()
sverde21 ::
- AFAIK class java.io.Console sploh ne obstaja, ker ga ni v manualu.
- v classu System ni metode console()
<?php echo `w`; ?>
Bojevnik ::
Console je prišel z verzijo 6.0 (imam javo 6.3):
http://java.sun.com/javase/6/docs/api/java/io/Console.html
http://java.sun.com/javase/6/docs/api/java/lang/System.html
http://java.sun.com/javase/6/docs/api/java/io/Console.html
http://java.sun.com/javase/6/docs/api/java/lang/System.html
Zgodovina sprememb…
- spremenilo: Bojevnik ()
kopernik ::
Osebno tega še nisem uporabljal, ampak mislim, da je pomemben naslednji odstavek iz dokumentacije :
Torej je mogoče, če zadevo poganjaš v kakšni skripti ali npr. Eclipsu, da zaradi kakšnih preusmeritev stdouta, sploh ne dobiš instance.
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.
Torej je mogoče, če zadevo poganjaš v kakšni skripti ali npr. Eclipsu, da zaradi kakšnih preusmeritev stdouta, sploh ne dobiš instance.
Vredno ogleda ...
Tema | Ogledi | Zadnje sporočilo | |
---|---|---|---|
Tema | Ogledi | Zadnje sporočilo | |
» | Java vector konstruktor = failure?Oddelek: Programiranje | 1039 (904) | arjan_t |
» | BigInteger-->BigDecimalOddelek: Programiranje | 949 (845) | FlashM |
» | [Java]Kopiranje tabelOddelek: Programiranje | 2096 (1978) | Steinkauz |
» | [JAVA] System_currentTimeMillis()??Oddelek: Programiranje | 812 (812) | kunigunda |
» | [java] opcijsko oknoOddelek: Programiranje | 2075 (1856) | infiniteLoop |