2 Replies Latest reply: Jan 25, 2010 3:45 AM by 843851 RSS

    java.lang.ClassNotFoundException: PPCalc

    843851
      Compilation is OK but execution gives me :" java.lang.ClassNotFoundException: PPCalc"

      here is the code :
      package PPCalc;
      
      import javax.microedition.lcdui.*;
      import javax.microedition.midlet.MIDlet;
      
      /**
       *
       * @author JmD
       */
      public class PPCalc extends MIDlet
        implements CommandListener {
        public Display display;
        static final Command CMD_GO = new Command("Calculer", Command.OK, 1);
        static final Command CMD_EXIT = new Command("Quitter", Command.EXIT, 1);
        public Form f1 = new Form("PPCalc");
        public TextField tfnom1 = new TextField("Proteines (g) ", "", 3, TextField.NUMERIC);
        public TextField tfnom2 = new TextField("Lipides     (g) ","",3,TextField.NUMERIC);
        public TextField tfnom3 = new TextField("Fibres      (g) ","",3,TextField.NUMERIC);
        public TextField tfnom4 = new TextField("Glucides  (g) ","",3,TextField.NUMERIC);
        public TextField tfnom5 = new TextField("Pour        (g) ","100",4,TextField.NUMERIC);
        public TextField tfnom6 = new TextField("Quantite  (g) ","100",4,TextField.NUMERIC);
      
      
        private int Pr;
        private int Gl;
        private int Li;
        private int Pour;
        private int Fi;
        private int Qte;
        private double resultat;
        private int x;
        private double p;
        public String al;
      
      
        public void PPCalc()
        {
      
      
          Pr = Integer.parseInt(Convert(tfnom1.getString().trim()));
          Li = Integer.parseInt(Convert(tfnom2.getString().trim()));
          Fi = Integer.parseInt(Convert(tfnom3.getString().trim()));
          Gl = Integer.parseInt(Convert(tfnom4.getString().trim()));
          Pour = Integer.parseInt(Convert(tfnom5.getString().trim()));
          Qte = Integer.parseInt(Convert(tfnom6.getString().trim()));
      
          p = 0;
          p = Pr/10;
          p += (Li)/4;
          p += Gl/10;
          p += Fi/30;
          p = p/10;
          resultat = p*Qte/Pour;
          al = "              ";
          al += Double.toString(resultat);
          al += " Points";
          Alerte("PPpoints",al);
        }
      
        private void Alerte(String titre,String a)
        {
          Alert avert = new Alert(titre, a, null, AlertType.INFO);
          avert.setTimeout(Alert.FOREVER);
          display.setCurrent(avert);
        }
      
      
      
        public void startApp()
        {
          display = Display.getDisplay(this);
          /*bcalc.setDefaultCommand(CMD_GO);
          bcalc.setItemCommandListener(this);*/
          f1.append(tfnom1);
          f1.append(tfnom2);
          f1.append(tfnom3);
          f1.append(tfnom4);
          f1.append(" ");
          f1.append(tfnom5);
          f1.append(tfnom6);
          /*f1.append(bcalc);*/
          f1.addCommand(CMD_GO);
          f1.addCommand(CMD_EXIT);
          f1.setCommandListener(this);
          display.setCurrent(f1);
        }
        private String Convert( String  T){
            String ab ="" ;
            int v;
            v=T.indexOf('.');
            if (v == -1){
                ab = T;
                ab.concat("0");
              }
            else{
              for(int i=1;i<v+1;i++){
                if (i != v)
                {
                    ab += T.charAt(i);
                }
              }
            }
            return ab;
        }
        public void pauseApp()
        {
        }
      
        public void destroyApp(boolean unconditional)
        {
          notifyDestroyed();
        }
      
        public void commandAction(Command c, Displayable d)
        {
          String str = c.getLabel();
          if (str.equals("Calculer"))
          {
            PPCalc();
          }
          else if (str.equals("Quitter")) {
            destroyApp(true);
            return;
        }
        }
      
      
      }
      Sorry if it is trivial to uou but I am a beginner on j2me developping..

      Many thanks for your help.