×

Discussion Board

Results 1 to 15 of 15
  1. #1
    Registered User
    Join Date
    May 2006
    Posts
    1

    Game crashes on Nokia 3650

    Hello,

    I've ported a j2me game to a nokia 3650 recently and I found three things wrong with it while playing it. I would either get dropped from the game without any error messages, get dropped from the game with an error message which says app@jes.microedition.lcdui.., or encounter a freeze. All of these happen unexpectedly and doesn't always happen at the same point at the same time. I can't find to seem the root of the problem. I suspect it's a heap problem but I've tried reducing some images and removing all the sounds but the problem still occurs. Can someone help me?

  2. #2
    Super Contributor
    Join Date
    Feb 2006
    Posts
    689

    Re: Game crashes on Nokia 3650

    Hi lla2,
    Can u be some more specific.I meant when you are encountering the problem.If possible can you please post the code where you see the problem.

    Thanks
    Soku

  3. #3
    Registered User
    Join Date
    May 2006
    Posts
    7

    error on the midlet

    hi my name is blandine and i need help i'm trying to devellop a computer game into a mobile phone , the problem is on the computer game there is a class call clickListener qui control the method mouse adapter which does not exist in j2me so when i try to preverify the class of the the game it tells me java/lang/NoClassDefFoundError: java/awt/event/MouseAdapter can anyone help me please

  4. #4
    Super Contributor
    Join Date
    Feb 2006
    Posts
    689

    Re: Game crashes on Nokia 3650

    Hi blandine_nzouonta,
    U cant use classes that are not defined in j2me.If u want to get noticed of any keyEvents use the default keylPressed,keyreleased,keyrepeated methods.Otherwise you can implement the commandListener interface and overide the commandAction method for the purpose..

    for knowing more about this check the link

    http://java.sun.com/developer/J2METe...01/tt0319.html

    thanks
    Soku

  5. #5
    Registered User
    Join Date
    May 2006
    Posts
    7

    still having problems running a j2me

    hi soku 123, thx for ur reply it was really helpful but now i created the classes but i still have this error protected void key pressed class or interface required and again before the game appear i need to click on a frame but i'm not sure that j2me run the frame and support applets pls help.

  6. #6
    Super Contributor
    Join Date
    Feb 2006
    Posts
    689

    Re: Game crashes on Nokia 3650

    Hi,
    Can you please post the part of the code that causes you the problem.I suppose you can just go through jsr 209.i am doubtfull whether it is available.But surely it is the Advanced Multimedia and UserInterface jsr and as your requirement it contains the awt package.

    Thanks
    Soku

  7. #7
    Registered User
    Join Date
    May 2006
    Posts
    7

    problem with j2me game

    ok thx for ur reply really and deeply appreciate it
    this is the application class: game.java

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


    interface Constants {
    public static final boolean
    DEBUG_ON = true;
    }

    public class game extends MIDlet {

    private Display myDisplay; //A reference to the physical display.
    private MyCanvas Canvas;
    private Form basicForm; //Stuff I want to show on the display.
    private Command exitCommand, moreCommand;
    private MyMines myCommands;

    public game(){

    //Get the reference to my display object.
    myDisplay = Display.getDisplay(this);
    Canvas = new MyCanvas(this);
    //Set up the soft keys.
    exitCommand = new Command("EXIT ", Command.EXIT, 2);
    moreCommand = new Command(" MORE", Command.SCREEN, 2);

    //Instantiate command listener.
    myCommands = new MyMines();

    //Form is derived from Screen - the basic display mechanism.
    basicForm = new Form("Hello World");
    //basicForm.append("Hi Bill!\n");
    basicForm.addCommand(moreCommand);
    basicForm.addCommand(exitCommand);
    basicForm.setCommandListener(myCommands);
    Debug.print("Hello constructed.");
    }

    private class MyMines implements CommandListener{
    //React to soft key(s).
    public void commandAction(Command c, Displayable d) {
    if(c == exitCommand) {
    Debug.print("Exit Soft Key!");
    //System.exit(0);
    destroyApp(false);
    notifyDestroyed();
    }
    if(c == moreCommand) {
    basicForm.append("You want more!?\n");
    Debug.print("MORE soft key pressed.");
    }
    }
    }

    // These are required to override abstract methods of MIDlet.
    public void startApp(){

    //Show my Form.
    myDisplay.setCurrent(Canvas);
    }
    //No actions needed.
    public void pauseApp(){}
    public void destroyApp(boolean unconditional){}
    }

    class Debug implements Constants {
    static void print(String s){
    if(Constants.DEBUG_ON == true) System.out.println(s);
    }
    }


    the class MyMines contain the game i have written in java that is minesweeper and the class ClickListener which does not allow me to see the midle as it uses mouseAdapeter as event and game is the midlet.

    this is GameCanvas.java

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



    public abstract class GameCanvas extends Canvas {
    protected game midlet;
    protected int fireKey;
    protected int leftKey;
    protected int rightKey;
    protected int upKey;
    protected int downKey;

    public GameCanvas( game midlet ){
    this.midlet = midlet;
    fireKey = getKeyCode( FIRE );
    leftKey = getKeyCode( LEFT );
    rightKey = getKeyCode( RIGHT );
    upKey = getKeyCode( UP );
    downKey = getKeyCode( DOWN );
    }
    }



    myCanvas.java

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

    public class MyCanvas extends Canvas {

    private game midlet;



    public MyCanvas( game midlet ){
    this.midlet = midlet;
    }

    protected void paint( Graphics g ){
    g.setColor( 255, 255, 255 );
    g.fillRect( 0, 0, getWidth(), getHeight() );
    g.setColor( 0, 0, 0 );
    g.drawString( "Hello there!", getWidth()/2, 0,
    g.TOP | g.HCENTER );
    }
    }



    protected void keyPressed( int keyCode )
    {
    if( keyCode == fireKey ){
    message = "FIRE";
    } else if( keyCode == leftKey ){
    message = "LEFT";
    } else if( keyCode == rightKey ){
    message = "RIGHT";
    } else if( keyCode == upKey ){
    message = "UP";
    } else if( keyCode == downKey ){
    message = "DOWN";
    } else {
    message = getKeyName( keyCode );
    }

    repaint();



    }
    }

    thank you for taking time to look at my problem really thx a lot

  8. #8
    Registered User
    Join Date
    May 2006
    Posts
    7

    error on the midlet

    ok forgot to post the error when i compile it


    C:\project\j2me\game\MyCanvas.java:27: 'class' or 'interface' expected
    protected void keyPressed( int keyCode )
    ^
    C:\project\j2me\game\MyCanvas.java:48: 'class' or 'interface' expected
    }
    ^
    C:\project\j2me\game\MyCanvas.java:54: 'class' or 'interface' expected
    ^
    3 errors

    Tool completed with exit code 1

    thx

  9. #9
    Registered User
    Join Date
    May 2006
    Posts
    7

    error on the midlet

    now i'm having one error because on the changes made on MyCanvas.java
    ok this is the code:

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

    public class MyCanvas extends Canvas {

    private game midlet;



    public MyCanvas( game midlet ){
    this.midlet = midlet;
    }

    protected void paint( Graphics g ){
    g.setColor( 255, 255, 255 );
    g.fillRect( 0, 0, getWidth(), getHeight() );
    g.setColor( 0, 0, 0 );
    g.drawString( "Hello there!", getWidth()/2, 0,
    g.TOP | g.HCENTER );
    }
    }

    class MyCanvas extends GameCanvas
    {

    void init(){

    }
    private String message = "Press any key";

    public MyCanvas( game midlet ){
    super( midlet );
    }

    protected void paint( Graphics g ){
    g.setColor( 255, 255, 255 );
    g.fillRect( 0, 0, getWidth(), getHeight() );
    g.setColor( 0, 0, 0 );
    g.drawString( message, getWidth()/2, 0,
    g.TOP | g.HCENTER );
    }

    protected void keyPressed( int keyCode ){
    if( keyCode == fireKey ){
    message = "FIRE";
    } else if( keyCode == leftKey ){
    message = "LEFT";
    } else if( keyCode == rightKey ){
    message = "RIGHT";
    } else if( keyCode == upKey ){
    message = "UP";
    } else if( keyCode == downKey ){
    message = "DOWN";
    } else {
    message = getKeyName( keyCode );
    }

    repaint();
    }
    }


    and this is the error:

    C:\project\j2me\game\MyCanvas.java:25: duplicate class: MyCanvas
    class MyCanvas extends GameCanvas
    ^
    1 error

    Tool completed with exit code 1

    ok really thx pls help!!!!!!

  10. #10
    Super Contributor
    Join Date
    Feb 2006
    Posts
    689

    Re: Game crashes on Nokia 3650

    Hi,
    For the first part of the code..It is a duplicate class(MYCanvas).Please change the class name.will reply you after looking into the later part of the code.

    thanks
    Soku

  11. #11
    Super Contributor
    Join Date
    Nov 2003
    Location
    Bangalore , India
    Posts
    4,430

    Re: Game crashes on Nokia 3650

    I tried compiling your code, and there were some errors in it. Just now managed to compile it and run. I have tried in WTK 2.3 Default emulator. Did not make any major changes other than error fix. Changed the keycode values in myCanvas.Java.
    Here is the code after error fix.

    Code:
    //game.java
    import javax.microedition.lcdui.*;
    import javax.microedition.midlet.*;
    
    
    interface Constants {
    public static final boolean
    DEBUG_ON = true;
    }
    
    public class game extends MIDlet {
    
    private Display myDisplay; //A reference to the physical display.
    private myCanvas Canvas;
    private Form basicForm; //Stuff I want to show on the display.
    private Command exitCommand, moreCommand;
    private MyMines myCommands;
    
    public game(){
    
    //Get the reference to my display object.
    myDisplay = Display.getDisplay(this);
    Canvas = new myCanvas(this);
    //Set up the soft keys.
    exitCommand = new Command("EXIT ", Command.EXIT, 2);
    moreCommand = new Command(" MORE", Command.SCREEN, 2);
    
    //Instantiate command listener.
    myCommands = new MyMines();
    
    //Form is derived from Screen - the basic display mechanism.
    basicForm = new Form("Hello World");
    //basicForm.append("Hi Bill!\n");
    basicForm.addCommand(moreCommand);
    basicForm.addCommand(exitCommand);
    basicForm.setCommandListener(myCommands);
    Debug.print("Hello constructed.");
    }
    
    private class MyMines implements CommandListener{
    //React to soft key(s).
    public void commandAction(Command c, Displayable d) {
    if(c == exitCommand) {
    Debug.print("Exit Soft Key!");
    //System.exit(0);
    destroyApp(false);
    notifyDestroyed();
    }
    if(c == moreCommand) {
    basicForm.append("You want more!?\n");
    Debug.print("MORE soft key pressed.");
    }
    }
    }
    
    // These are required to override abstract methods of MIDlet.
    public void startApp(){
    
    //Show my Form.
    myDisplay.setCurrent(Canvas);
    }
    //No actions needed.
    public void pauseApp(){}
    public void destroyApp(boolean unconditional){}
    }
    
    class Debug implements Constants {
    static void print(String s){
    if(Constants.DEBUG_ON == true) System.out.println(s);
    }
    }
    Code:
    //GameCanvas.java
    import javax.microedition.lcdui.*;
    import javax.microedition.midlet.*;
    
    public abstract class GameCanvas extends Canvas {
    protected game midlet;
    protected int fireKey;
    protected int leftKey;
    protected int rightKey;
    protected int upKey;
    protected int downKey;
    
    public GameCanvas( game midlet ){
    this.midlet = midlet;
    fireKey = getKeyCode( FIRE );
    leftKey = getKeyCode( LEFT );
    rightKey = getKeyCode( RIGHT );
    upKey = getKeyCode( UP );
    downKey = getKeyCode( DOWN );
    }
    }
    Code:
    //myCanvas.java
    import javax.microedition.lcdui.*;
    import javax.microedition.midlet.*;
    
    public class myCanvas extends Canvas {
    
    private game midlet;
    
    public String message;
    
    public myCanvas( game midlet ){
    this.midlet = midlet;
    }
    
    protected void paint( Graphics g ){
    g.setColor( 255, 255, 255 );
    g.fillRect( 0, 0, getWidth(), getHeight() );
    g.setColor( 0, 0, 0 );
    g.drawString( "Hello there!"+message, getWidth()/2, 0,
    g.TOP | g.HCENTER );
    }
    
    protected void keyPressed( int keyCode )
    {
    if( keyCode == -5 ){
    message = "FIRE";
    } else if( keyCode == -3 ){
    message = "LEFT";
    } else if( keyCode == -4 ){
    message = "RIGHT";
    } else if( keyCode == -1 ){
    message = "UP";
    } else if( keyCode == -2 ){
    message = "DOWN";
    } else {
    message = getKeyName( keyCode );
    }
    
    repaint();
    
    
    
    }
    }
    Regards
    Gopal

  12. #12
    Registered User
    Join Date
    May 2006
    Posts
    7

    Re: Game crashes on Nokia 3650

    THX FOR UR HELP I REALLY APPRECIATE IT, you see the aim was to be able to read the class MyMines which is the game i wrote in java but it is not showing still giving me errors when i run the midlet sorry but i'm new with j2me so pls if i want to read the class MyMines in the midlet is my code i mean game.java written in the good way or i need to change it cause i dont understand
    so here is my main code of MyMines.java which is the game minesweeper
    Code:
    /*  MyMines.java  */
    import javax.swing.*;
    import javax.swing.border.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    import java.net.*;
    
    public class MyMines extends JApplet {
    
        //The applet which instantiate the start button
        Container appletPane;
        JButton startButton;
        Border raisedBorder;
        ImageIcon bigSmile;
        URL codeBase;
    
        //The Frame, which is the game board.
        JFrame game;
        Container gamePane;
        JMenuBar menuBar;
        GameMenu gameMenu;
        HelpMenu helpMenu;
        Smiley smiley;          //The smiley face button that starts a new game.
        MineCnt unmarkedMines;  //The counter for unmarked mines.
        LEDtime seconds;        //Elapsed time since the first move.
        Sea mySea;              //The grid of sea cells that forms the playing area.
        DebugText debugText;    //Optional area for writing debug messages.
    
        boolean firstGame = true;
        boolean activeGame = false;
    
        public void init()  {
           appletPane = getContentPane();
           codeBase = getCodeBase();
           //mine1 = new ImageIcon(getImage(codeBase, "mine1.gif"));
           //mine 1 = new ImageIcon(getImage(codeBase, "mine1.gif"));
           startButton = new JButton("Minesweeper");
           //startButton size is set by Applet dimensions in html file.
           startButton.setDefaultCapable(false);
           raisedBorder = BorderFactory.createBevelBorder(BevelBorder.RAISED);
           startButton.setBorder(raisedBorder);
           startButton.addActionListener(new ActionListener() {
    		  public void actionPerformed(ActionEvent e) {
    			  if(!activeGame) {
    				  activeGame = true;
    				  runGame();
    		      }
    	      }
           });
          appletPane.add(startButton);
        }
    
        class WindowCloseListener extends WindowAdapter {
    	   public void windowClosed(WindowEvent e) {
    		   activeGame = false;
           }
        }
    
        void runGame() {
    		game = new JFrame("Minesweeper");
    		game.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    		Game.setStarter();
    		game.setSize(Game.width, Game.height);
    		game.setResizable(false);
    		game.setLocationRelativeTo(null);  //Center game on screen.
    		menuBar = new JMenuBar();
    		gameMenu = new GameMenu(this);
    		helpMenu = new HelpMenu(this);
    		smiley = new Smiley(this);
    		unmarkedMines = new MineCnt(this);
    		seconds = new LEDtime(this);
    		debugText = new DebugText();
    
    		gamePane = game.getContentPane();
    		gamePane.setLayout(new FlowLayout());
    		//Build the menu bar.
    		menuBar.add(gameMenu);
    		menuBar.add(helpMenu);
    
    		game.setJMenuBar(menuBar);
            gamePane.add(unmarkedMines.getJPanel());  //Component0
            gamePane.add(smiley);                     //Component1
            gamePane.add(seconds.getJPanel());        //Component2
            setupNewGame(false);                      //Installs Component3
            if(debugText.isDebugEnabled()) {          //Component4
    			gamePane.add(debugText.getDebugPane());
    	    }
    
    	    game.addWindowListener(new WindowCloseListener());
    	    game.setVisible(true);
       }
    
       void setupNewGame(boolean sizeChange) {
    	   Game.started = false;
    	   Game.over = false;
    	   unmarkedMines.initialize();
    	   seconds.reset();
    	   debugText.reset();
    	   //Do we need to remove an existing mySea?
    	   if(firstGame)  {
    		  firstGame = false;
    		  mySea = new Sea(this, debugText, unmarkedMines, smiley);
    		  gamePane.add(mySea.getJPanel(),3);
    	    }
    	    else {
    			gamePane.remove(mySea.getJPanel());
    			mySea = new Sea(this, debugText, unmarkedMines, smiley);
    			smiley.setSmile();
    			gamePane.add(mySea.getJPanel(),3);
    			if(sizeChange) {
    			   game.setSize(new Dimension(Game.width,Game.height));
                   game.setLocationRelativeTo(null);  //Center game on screen.
    		    }
    		    game.setVisible(true);         //Force frame to repaint.
    
            }
         }//End setupNewGame.
    
      }//End MyMines.

    and this is the class where j2me have problem reading
    Code:
    /* ClickListener.java */
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    
    public class ClickListener extends MouseAdapter {
      private JTextArea debugText;
      private boolean
         leftPressed = false,
         rightPressed = false,
         bothPressed = false,
         leftReleased = false,
         rightReleased = false;
      private String buttonLabel;
      Sea.SeaButton myButton;
    
      public ClickListener(JTextArea debugText, Sea.SeaButton myButton) {
          //Save a reference to the debug output object.
          this.debugText = debugText;
          this.myButton = myButton;
          buttonLabel = myButton.buttonLabel;
      }
    
      public void mousePressed(MouseEvent e) {
          if(SwingUtilities.isLeftMouseButton(e))
             leftPressed = true;
          if(SwingUtilities.isRightMouseButton(e))
             rightPressed = true;
          if(leftPressed && rightPressed)
             bothPressed = true;
      }//End mousePressed.
    
      public void mouseReleased(MouseEvent e) {
            if(SwingUtilities.isLeftMouseButton(e))
               leftReleased = true;
            if(SwingUtilities.isRightMouseButton(e))
               rightReleased = true;
            if(leftReleased && rightReleased) {
               bothClick();
               clearAll();
            }
          else { //Single click.
            if(SwingUtilities.isLeftMouseButton(e) && leftPressed) {
               leftClick();
            }  else if (SwingUtilities.isRightMouseButton(e) && rightPressed) {
               rightClick();
            }
            clearAll();
         }
      }//End mouseReleased.
    
      private void clearAll() {
          leftPressed = rightPressed = false;
          bothPressed = false;
          leftReleased = rightReleased = false;
      }
    
      void bothClick() {
         debugText.append(buttonLabel + "Both click\n");
         myButton.revealAdjacent();
      }
    
      void leftClick() {
         /* Left click is the "reveal" function. It reveals the contents of the,
         which can be a mine or an adjacent mine count. if a mine, you lose.
         if an adjacent mine count of zero, the reveals spreads to reveal a boundary
         ring of non-zero adjacent mine count. */
         debugText.append(buttonLabel + "Left click\n");
         myButton.reveal();
         //First leftClick in a new game starts the timer.
         Game.started = true;
      }
    
      void rightClick() {
         debugText.append(buttonLabel + "Right click\n");
         myButton.mark();
    
      }
    
    }//End ClickListener.
    though this is not all the code of the game can u pls pls tell me if i need to create an interface in j2me or i can just create a midlet which is going to accept this and more but i guess these are the classes which cannot be read
    thx again for ur time

  13. #13
    Super Contributor
    Join Date
    Mar 2006
    Posts
    516

    Re: Game crashes on Nokia 3650

    Hi blandine,

    I have already replied to ur posting here
    http://discussion.forum.nokia.com/fo...ad.php?t=77680

    Please don't do double posting. It may cause confusion to others who are searching the forum in future


    U have to change the whole code completely. This is because Swing is not supported in J2ME. Since u have done the code in simple java, u don't have to change the logic of the game.

    U can use form instead of swing.
    if u want better look & feel u require canvas drawing

    Wang

  14. #14
    Registered User
    Join Date
    Apr 2006
    Posts
    13

    Re: Game crashes on Nokia 3650

    Quote Originally Posted by lla2
    Hello,

    I've ported a j2me game to a nokia 3650 recently and I found three things wrong with it while playing it. I would either get dropped from the game without any error messages, get dropped from the game with an error message which says app@jes.microedition.lcdui.., or encounter a freeze. All of these happen unexpectedly and doesn't always happen at the same point at the same time. I can't find to seem the root of the problem. I suspect it's a heap problem but I've tried reducing some images and removing all the sounds but the problem still occurs. Can someone help me?
    hi,
    This mostly happen because of following reason.
    1. Heap Memory
    In s60 series phone there is no limitation for memory. but the memory assigned to application is limited if the application needs more memory than the provided then a concept called Growing Memory comes in to picture.The concept says that if the total memory is 10Mb (assume)then out of these only 5Mb is given to an application and depending up on the suitation the memory is increased ie if the application need some more memory then 2Mb is given to it. it continue till all the memory is used.
    Now problem with u may be that you may not be following the same flow of sequence each time. so does not happen at the same point at the same time.
    2. Long Function
    It may be possible that you are using long funtion which makes insufficent for the compilier to load and exceute it. you can just break the fuction into small subfunction.
    3. More Local Variable
    It may be possible that u may are using more local variable with in the fuction and calling this function repeatedly i.e. in paint(). just declare these variable globelly and create onces.
    4. paint method is sychronize
    Try by removing sychronize of paint method

    Thanx
    shagish.k

  15. #15
    Registered User
    Join Date
    Jan 2008
    Posts
    37

    Re: Game crashes on Nokia 3650

    Hi, Blandine and lla2

    Then how you resolved this problem,

    Can you help me, to resolve a similar problem which I am facing
    http://discussion.forum.nokia.com/fo...d.php?t=128549

    I will be Thank Full
    Huzefa

Similar Threads

  1. which phones for laptop
    By dvdljns in forum PC Suite API and PC Connectivity SDK
    Replies: 2
    Last Post: 2006-02-14, 12:58
  2. SMS archive from NOKIA 3650 to Nokia 6600
    By radiodj105 in forum General Development Questions
    Replies: 1
    Last Post: 2005-09-04, 18:34
  3. Nokia 3650 and "AT+CPBR" command
    By ahanke in forum Bluetooth Technology
    Replies: 1
    Last Post: 2003-07-14, 09:02
  4. Porting a Nokia 7650 game to a Nokia 3650
    By faisal20 in forum Symbian C++
    Replies: 0
    Last Post: 2003-03-10, 14:47
  5. Socket on Nokia 3650
    By flexsys in forum Symbian Tools & SDKs
    Replies: 1
    Last Post: 2003-02-20, 08:09

Posting Permissions

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