Java ME Prog aus Buch funzt nicht!

Big Masie

Mitglied
Hallo,

ich hab aus meinem Java ME Buch ein kleines Prog ab programmiert, aber es funzt nicht einfach nich :(


hier mal der fehler:

\NetBeansProjects\HalloWelt\nbproject\build-impl.xml:898: Execution failed with error code 1.
ERSTELLEN FEHLGESCHLAGEN (Gesamtzeit: 0 Minuten 22 Sekunden)

(Ich benutz Netbeans)

und das ist der Quellcode:

Java:
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;

public class HalloWelt extends MIDlet implements CommandListener
{
    Display display;
    private Command
            menu1 = new Command("Hallo", Command.ITEM, 1),
            menu2 = new Command("Welt", Command.ITEM, 1),
            menu3 = new Command("!", Command.ITEM, 1),
            menu4 = new Command("Umbruch", Command.ITEM, 1),
            menuExit = new Command("Verlassen", Command.ITEM, 1);

    private Form f = new Form("Hallo Welt Form");

    public HalloWelt()
    {
        f.append("Hallo Welt!\n");
        f.addCommand(menu1);
        f.addCommand(menu2);
        f.addCommand(menu3);
        f.addCommand(menu4);
        f.addCommand(menuExit);
        f.setCommandListener(this);
    }

    public void startApp() throws MIDletStateChangeException
    {
        display = Display.getDisplay(this);
        display.setCurrent(f);
    }

    public void pauseApp()
    {
    }

    public void destroyApp(boolean unconditional)
    {   
    }

    public void commandAction(Command c, Displayable s)
    {
        if(c == menuExit)
            notifyDestroyed();
        else if(c == menu1)
            f.append("Hallo ");
        else if(c == menu2)
            f.append("Welt");
        else if(c == menu3)
            f.append("!");
        else if(c == menu4)
            f.append("\n");
    }
}
 
M

MiDniGG

Gast
Also bei mir funktioniert alles ohne Probleme... Hab zwar den Code etwas umgestellt, sollte aber nichts ändern...

Java:
public class HelloWorld extends MIDlet implements CommandListener {
    private Display    display        = null;
    private Command    menu1        = null;
    private Command    menu2        = null;
    private Command    menu3        = null;
    private Command    menu4        = null;
    private Command    menuExit    = null;
    private Form    f            = null;
    public HelloWorld() {
        f = new Form("Hallo Welt Form");
        menu1 = new Command("Hallo", Command.ITEM, 1);
        menu2 = new Command("Welt", Command.ITEM, 1);
        menu3 = new Command("!", Command.ITEM, 1);
        menu4 = new Command("Umbruch", Command.ITEM, 1);
        menuExit = new Command("Verlassen", Command.ITEM, 1);
        f.append("Hallo Welt!\n");
        f.addCommand(menu1);
        f.addCommand(menu2);
        f.addCommand(menu3);
        f.addCommand(menu4);
        f.addCommand(menuExit);
        f.setCommandListener(this);
    }
    protected void destroyApp(boolean unconditional) throws MIDletStateChangeException {}
    protected void pauseApp() {}
    protected void startApp() throws MIDletStateChangeException {
        display = Display.getDisplay(this);
        display.setCurrent(f);
    }
    public void commandAction(Command c, Displayable d) {
        if(c==menuExit)
            notifyDestroyed();
        else if(c==menu1)
            f.append("Hallo ");
        else if(c==menu2)
            f.append("Welt");
        else if(c==menu3)
            f.append("!");
        else if(c==menu4)
            f.append("\n");
    }
}

Bau doch mal ein paar System.out.println(); ein, sodass Du weißt, wo das Teil auf die Schnauze fliegt...
 

Big Masie

Mitglied
ich hab festgestellt das er nichtmal mehr die vorgefertigten beispiel progs von netbeans kompeliert ... -.-

aber ich versteh das nicht, ... er hat doch zuvor alles gemacht :(
 

Ähnliche Java Themen

Neue Themen


Oben