Novo

Forum kao aplikacija na telefonu

Dodajte forum na početni ekran i koristite ga kao aplikaciju, sa menijem na dnu ekrana.

Nemam konzolu kad koristim IDE: i Eclipse i IntelliJIdea? i Console klasu

  • 1 odgovor
  • 3.235 pregleda

Najnovija ↓

Nemam konzolu kad koristim IDE: i Eclipse i IntelliJIdea? i Console klasu 04.11.2007. u 20:42 · pre 231 mesec #1
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!
Potpis
signature error
Re: Nemam konzolu kad koristim IDE: i Eclipse i IntelliJIdea? i Console klasu 05.11.2007. u 00:23 · pre 231 mesec #2
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.

Potpis
Free advice is seldom cheap.
Prijavite se da biste odgovorili u ovoj temi.PrijavaRegistracija

Premeštanje teme