IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Java ME Discussion :

Probleme de debugage


Sujet :

Java ME

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Profil pro
    Inscrit en
    Janvier 2007
    Messages
    16
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2007
    Messages : 16
    Par défaut Probleme de debugage
    Salut a tous,
    je fait une application avec J2ME voila le code
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;
    import javax.microedition.rms.RecordStore;
    import javax.microedition.rms.*;
    import javax.microedition.lcdui.ChoiceGroup;
    
    
    public class HelloMidlet extends MIDlet implements CommandListener{    
        
        public String[] tab_teams;
        public String[] tab_id;
        private Form helloForm;
        private Form TeamSelect;
        private ChoiceGroup choiceGroup1;
        private Ticker ticker1;
        private Command exitCommand;
        private Command okCommand;
        private StringItem stringItem1;
        
        private void initialize(){
            try
            {
                RecordStore DATA = RecordStore.openRecordStore("Teams",true);
                byte[] arsenal = "Arsenal".getBytes();
                byte[] manutd = "MancehsterUnited".getBytes();
                byte[] chelsea = "Chelsea".getBytes();
                byte[] liverpool = "Liverpool".getBytes();
                DATA.addRecord(arsenal,0,arsenal.length);
                DATA.addRecord(manutd,0,manutd.length);
                DATA.addRecord(chelsea,0,chelsea.length);
                DATA.addRecord(liverpool,0,liverpool.length);     
                //
                tab_teams=new String[DATA.getNumRecords()+1];
                tab_id=new String[DATA.getNumRecords()+1];
                for(int i=0;i<DATA.getNumRecords();i++)
                {
                    String temp = new String(DATA.getRecord(i));
                    int id = DATA.getNextRecordID();
                    tab_id[i]=""+id;
                    tab_teams[i]=temp;
                }
                DATA.closeRecordStore();
            }
            catch(Exception e){}
            getDisplay().setCurrent(get_helloForm());
            }
       
        
        //
        //
        //
        //
        public void commandAction(Command command, Displayable displayable) {
            if (displayable == helloForm) {
                if (command == exitCommand) {
                    exitMIDlet();
                } else if(command == okCommand) {
                    getDisplay().setCurrent(get_TeamSelect());
                }
            } else if (displayable == TeamSelect) {
                if (command == exitCommand) {
                    exitMIDlet();
                } else if (command == okCommand) {
    
                }
            }
    }
        public void exitMIDlet() {
            getDisplay().setCurrent(null);
            destroyApp(true);
            notifyDestroyed();
        }
        //Forms
        public Form get_TeamSelect() {
            if (TeamSelect == null) {
                TeamSelect = new Form("Your Team", new Item[]{get_choiceGroup1()});
                TeamSelect.addCommand(get_exitCommand());
                TeamSelect.addCommand(get_okCommand1());
                TeamSelect.setCommandListener(this);
            }
            return TeamSelect;
        }
        public Form get_helloForm() {
            if (helloForm == null) {
                helloForm = new Form("Football Manager", new Item[] {get_stringItem1()});
                helloForm.addCommand(get_exitCommand());
                helloForm.addCommand(get_okCommand1());
                helloForm.setCommandListener(this);
                helloForm.setTicker(get_ticker1());
            }
            return helloForm;
        }
        //Items
        public ChoiceGroup get_choiceGroup1(){
            if (choiceGroup1 == null){
                choiceGroup1 = new ChoiceGroup("Select Team",Choice.EXCLUSIVE,tab_teams,null);
                choiceGroup1.setSelectedFlags(new boolean[] {
                    false,
                    false
                });
            }
            return choiceGroup1;
        }
        public StringItem get_stringItem1() {
            if (stringItem1 == null) {
                stringItem1 = new StringItem("by Edi Kitar", "");
                stringItem1.setLayout(Item.LAYOUT_CENTER);
            }
            return stringItem1;
        }
        
        public Ticker get_ticker1() {
            if (ticker1 == null) {
                ticker1 = new Ticker("The New Premiership Football Manager");
            }
            return ticker1;
        }
        //Commands
        public Command get_okCommand1() {
            if (okCommand == null) {
                okCommand = new Command("Ok", Command.OK, 1);
            }
            return okCommand;
        }
        public Command get_exitCommand() {
            if (exitCommand == null) {
                exitCommand = new Command("Exit", Command.EXIT, 1);
            }
            return exitCommand;
        }
        public Display getDisplay() {
            return Display.getDisplay(this);
        }
        public HelloMidlet(){ initialize();}
        public void startApp() {}
        public void pauseApp() {}
        public void destroyApp(boolean unconditional) {}
    
    Quand je compile il n'y a pas de problemes mais au moment quand je lance le simulateur il m'affiche dans le output
    java.lang.NullPointerException
    at HelloMidlet.get_choiceGroup1(HelloMidlet.java:96)
    at HelloMidlet.get_TeamSelect(HelloMidlet.java:76)
    at HelloMidlet.commandAction(HelloMidlet.java:58)


    Normalement c'est un probleme d'allocation et je suis sur que c'est lie a l'utilisation de RMS et plus exactement tab_teams

    Est-ce que quelqu'un peut m'aider a debouger cette application?

    Merci d'avance

  2. #2
    Membre averti
    Profil pro
    Inscrit en
    Janvier 2007
    Messages
    16
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2007
    Messages : 16
    Par défaut
    J'ai travaille toute la soiree et maintenant je suis sur que le probleme c'est la creation de la tab_teams qui se fait a partir de la base de donnees. Est-ce que qqn voit une erreur dans le code de la base parce ce que je suis persuade qu'elle n'existe meme pas?


    Merci encore une fois aux gens qui peuvent m'aider

  3. #3
    Membre averti
    Profil pro
    Inscrit en
    Décembre 2006
    Messages
    18
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2006
    Messages : 18
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    tab_teams=new String[DATA.getNumRecords()+1];
    Pourquoi ce +1, qui n'est pas rempli dans la boucle for suivante donc un null à la fin du tableau, ce qui doit entrainer ce nullexception.

    Mik

  4. #4
    Membre averti
    Profil pro
    Inscrit en
    Janvier 2007
    Messages
    16
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2007
    Messages : 16
    Par défaut
    Merci c'etais deja un pas en avant,

    mais l'application ne marche pas encore. J'ai ajoute un RecordEnumeration et au moins il n'y a plus le nullpointerexception donc tab_teams existe mais n'ai pas initialisee parce que mon choiceGroup n'affiche rien.
    le nouveau code de la RMS est
    try
    {
    DATA = RecordStore.openRecordStore("Teams",true);
    RecordEnumeration re = DATA.enumerateRecords(null,null,false);
    byte[] arsenal = "Arsenal".getBytes();
    byte[] manutd = "MancehsterUnited".getBytes();
    byte[] chelsea = "Chelsea".getBytes();
    byte[] liverpool = "Liverpool".getBytes();
    DATA.addRecord(arsenal,0,arsenal.length);
    DATA.addRecord(manutd,0,manutd.length);
    DATA.addRecord(chelsea,0,chelsea.length);
    DATA.addRecord(liverpool,0,liverpool.length);
    //
    tab_teams=new String[re.numRecords()];
    for (int i=0;i<re.numRecords();i++)
    {
    String temp = new String(DATA.getRecord(i));
    tab_teams[i]=temp;
    }
    DATA.closeRecordStore();
    }
    catch(RecordStoreException e){}


    et chaque fois quand je veux utiliset DATA.getNumRecords() il me donne nullpointerexception

    apres j'ai trouver que re.numRecord() = 0 et je ne comprends pas pourquoi
    c'est pour ca que je n'ai rien dans tab_teams. la boucle ne s'exute mem pas

    Si qqn voit une erreur merci de me l'indiquer.

  5. #5
    Membre averti
    Profil pro
    Inscrit en
    Janvier 2007
    Messages
    16
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2007
    Messages : 16
    Par défaut
    J'ai resolu le probleme
    tout etait dans la declaration de la tab_teams
    c'etait public au lieu de private

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. probleme de debugage
    Par Momo23 dans le forum VC++ .NET
    Réponses: 2
    Dernier message: 06/04/2012, 12h46
  2. [IDE] Problème avec le debugage
    Par Michel DELAVAL dans le forum Access
    Réponses: 12
    Dernier message: 28/09/2006, 10h40
  3. problème lié au debugage
    Par pellec dans le forum Access
    Réponses: 3
    Dernier message: 12/09/2006, 09h56
  4. [Kylix] Probleme d'execution de programmes...
    Par yopziggy dans le forum EDI
    Réponses: 19
    Dernier message: 03/05/2002, 14h50
  5. [Kylix] Probleme de nombre flottant!!
    Par yopziggy dans le forum EDI
    Réponses: 5
    Dernier message: 02/05/2002, 10h13

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo