Results 1 to 7 of 7
  1. #1
    ryanlcc is offline Member
    Join Date
    Jul 2010
    Posts
    5
    Rep Power
    0

    Default My program complied nicely but there is error when running

    I am using netbean 6.8 and has not problem compiling...somehow, once start, it gives me this error..

    Not able to submit breakpoint MethodBreakpoint [Calculator].jblnit '()Lvoid;', reason: Method 'jblnit' with signature '()Lvoid;' does not exist in class Calculator.

    below are my code..



    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;
    import javax.microedition.lcdui.ChoiceGroup;

    public class Calculator extends MIDlet implements CommandListener{

    private StringItem st, output;
    private Command exit = new Command("Exit", Command.EXIT,0);
    private Command menu = new Command("Menu", Command.SCREEN,1);
    private int answer=0, x1, x2;
    private TextField input1, input2;
    private String ope[] = new String[]{"+", "-", "*", "/"};
    private ChoiceGroup ch = new ChoiceGroup("Select operation:",ChoiceGroup.EXCLUSIVE,ope,null);


    public void startApp() {
    Form mycalculator = new Form("Welcome to 'My Calculator'");

    Alert alertmsg = new Alert("WELCOME", "ENJOY USNG THIS CALCULATOR",null,AlertType.CONFIRMATION);

    st = new StringItem(null,"Welcome ! This calculator allows you to do addition(+),substraction(-), multiplication(*) and division(/)");

    input1 = new TextField("Enter your first number :","",15,TextField.NUMERIC);
    input2 = new TextField("Enter your second number :","",15,TextField.NUMERIC);

    mycalculator.append(st);
    Display.getDisplay(this).setCurrentItem(st);

    mycalculator.append(input1);
    mycalculator.append(ch);
    mycalculator.append(input2);
    mycalculator.append(output);
    alertmsg.setTimeout(Alert.FOREVER);

    mycalculator.addCommand(exit);
    mycalculator.addCommand(menu);
    mycalculator.setCommandListener(this);


    }

    public void pauseApp() {
    }

    public void destroyApp(boolean unconditional) {
    }

    public void commandAction(Command c, Displayable d){

    if(c == menu){

    x1=Integer.parseInt(input1.getString());
    x2=Integer.parseInt(input2.getString());
    int operation = ch.getSelectedIndex();

    switch(operation){
    case 0: answer = x1 + x2;
    output.setText("Answer = "+answer);
    break;
    case 1: answer = x1 - x2;
    output.setText("Answer = "+answer);
    break;
    case 2: answer = x1 * x2;
    output.setText("Answer = "+answer);
    break;
    case 3: answer = x1 / x2;
    output.setText("Answer = "+answer);
    break;
    }

    }
    }
    }
    Attached Thumbnails Attached Thumbnails My program complied nicely but there is error when running-captureerror.jpg  
    Last edited by ryanlcc; 07-10-2010 at 01:19 PM.

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,518
    Rep Power
    25

    Default

    Method 'jblnit'
    Where is this method defined? The JVM can't find it to call it.

  3. #3
    ryanlcc is offline Member
    Join Date
    Jul 2010
    Posts
    5
    Rep Power
    0

    Default

    Very sorry...I am still newbie here..Perhaps, a noob...

    is it

    public jblnit() {
    }

  4. #4
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,570
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by ryanlcc View Post
    reason: Method 'jblnit' with signature '()Lvoid;' does not exist in class Calculator.
    Chinese is not your native language is it? Good, because the message above is not in Chinese. What part of it didn't you understand and what caused it that you blindly dumped your code in here? Did it ever occur to you that reading (parts of) a manual might help?

    kind regards,

    Jos

  5. #5
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,518
    Rep Power
    25

    Default

    is it

    public jblnit() {
    }
    You'll have to read the API doc to see how and where that method is used for.
    Your code shows the syntax for a constructor not a method.

  6. #6
    ryanlcc is offline Member
    Join Date
    Jul 2010
    Posts
    5
    Rep Power
    0

    Default

    i have corrected my code but still giving the same problem...
    with the error message
    Attaching to localhost:56070
    Not able to submit breakpoint FieldBreakpoint MyCalculator.cg, reason: The target VM does not support field access breakpoints.
    Not able to submit breakpoint FieldBreakpoint MyCalculator.ope, reason: The target VM does not support field access breakpoints.


    /*
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    */

    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;
    import javax.microedition.lcdui.ChoiceGroup;
    import javax.microedition.lcdui.CommandListener;
    /**
    * @author RyanLCC
    */
    public class Midlet_1 extends MIDlet implements CommandListener{

    private Display d;
    private Form mycalculator;
    private StringItem st, output;
    private Command exit = new Command("Exit", Command.EXIT,0);
    private Command menu = new Command("Menu", Command.SCREEN,1);
    private int answer=0, x1, x2;
    private TextField input1, input2;
    private String ope[] = new String[]{"+", "-", "*", "/"};
    private ChoiceGroup ch = new ChoiceGroup("Select operation:",ChoiceGroup.EXCLUSIVE,ope,null);


    public Midlet_1(){
    mycalculator = new Form("Welcome to 'My Calculator'");

    Alert alertmsg = new Alert("WELCOME", "ENJOY USNG THIS CALCULATOR",null,AlertType.CONFIRMATION);

    st = new StringItem(null,"Welcome ! This calculator allows you to do addition(+),substraction(-), multiplication(*) and division(/)");

    input1 = new TextField("Enter your first number :","",15,TextField.NUMERIC);
    input2 = new TextField("Enter your second number :","",15,TextField.NUMERIC);

    mycalculator.append(st);
    mycalculator.append(input1);
    mycalculator.append(ch);
    mycalculator.append(input2);
    mycalculator.append(output);
    alertmsg.setTimeout(Alert.FOREVER);

    mycalculator.addCommand(exit);
    mycalculator.addCommand(menu);
    mycalculator.setCommandListener(this);

    }

    public void startApp() {
    d= Display.getDisplay(this);
    d.setCurrent(mycalculator);

    }

    public void pauseApp() {
    }

    public void destroyApp(boolean unconditional) {
    }

    public void commandAction(Command c, Displayable d){

    if(c == menu){

    x1=Integer.parseInt(input1.getString());
    x2=Integer.parseInt(input2.getString());
    int operation = ch.getSelectedIndex();

    switch(operation){
    case 0: answer = x1 + x2;
    output.setText("Answer = "+answer);
    break;
    case 1: answer = x1 - x2;
    output.setText("Answer = "+answer);
    break;
    case 2: answer = x1 * x2;
    output.setText("Answer = "+answer);
    break;
    case 3: answer = x1 / x2;
    output.setText("Answer = "+answer);
    break;
    }

    }
    }
    }

  7. #7
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,518
    Rep Power
    25

    Default

    I guess its time to read the doc for the environment that you are trying to run this code in.

Similar Threads

  1. my program is running bit slow!!
    By Arn00p in forum AWT / Swing
    Replies: 18
    Last Post: 05-05-2010, 04:14 PM
  2. Program running indefinitely
    By bayan in forum New To Java
    Replies: 2
    Last Post: 04-27-2010, 09:22 AM
  3. Running a Java Program
    By Valkyrie in forum New To Java
    Replies: 13
    Last Post: 11-05-2009, 03:43 AM
  4. Error running java program using URL
    By gio123bg in forum New To Java
    Replies: 6
    Last Post: 06-30-2009, 06:26 PM
  5. error running java program
    By bdasilva in forum New To Java
    Replies: 1
    Last Post: 06-29-2009, 01:46 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •