ALERT: java/lang/ClassFormatError: Bad version information.
3 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Friday, March 13, 2009 05:36 AM

I got the following exception when I try to my little applicaiton. ALERT: java/lang/ClassFormatError: Bad version information. I googled a lot. Some people say it is because of the JDK version as JDK1.5 and upper do not support J2me (Really?). However, even I tried 1.4, it still get me the same error. Any one can help me out please? package hongliang; import javax.microedition.midlet.*; import javax.microedition.lcdui.*; public class ExampleGameSpriteMidlet extends MIDlet { private Display display; public void startApp() { try { display = Display.getDisplay(this); ExampleGameCanvas gameCanvas = new ExampleGameCanvas(); gameCanvas.star   More>>


I got the following exception when I try to my little applicaiton.
ALERT: java/lang/ClassFormatError: Bad version information.

I googled a lot. Some people say it is because of the JDK version as JDK1.5 and upper do not support J2me (Really?). However, even I tried 1.4, it still get me the same error. Any one can help me out please?


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

public class ExampleGameSpriteMidlet extends MIDlet {
private Display display;

public void startApp() {
try {
display = Display.getDisplay(this);
ExampleGameCanvas gameCanvas = new ExampleGameCanvas();
gameCanvas.start();
display.setCurrent(gameCanvas);
} catch (Exception ex) {
System.out.println(ex);
}
}

public Display getDisplay() {
return display;
}

public void pauseApp() {
}

public void destroyApp(boolean unconditional) {
exit();
}

public void exit() {
System.gc();
destroyApp(false);
notifyDestroyed();
}
}



package hongliang;
import javax.microedition.lcdui.*;
import javax.microedition.lcdui.game.*;

public class ExampleGameCanvas extends GameCanvas implements Runnable {
private boolean isPlay; // Game Loop runs when isPlay is true
private long delay; // To give thread consistency
private int currentX, currentY; // To hold current position of the 'X'
private int width; // To hold screen width
private int height; // To hold screen height

// Sprites to be used
private Sprite sprite;
private Sprite nonTransparentSprite;

// Constructor and initialization
public ExampleGameCanvas() throws Exception {
super(true);
width = getWidth();
height = getHeight();
currentX = width / 2;
currentY = height / 2;
delay = 20;

// Load Images to Sprites
Image image = Image.createImage("/transparent.png");
sprite = new Sprite (image,32,32);

Image imageTemp = Image.createImage("/nontransparent.png");
nonTransparentSprite = new Sprite (imageTemp,32,32);

}

// Automatically start thread for game loop
public void start() {
isPlay = true;
Thread t = new Thread(this);
t.start();
}

public void stop() { isPlay = false; }

// Main Game Loop
public void run() {
Graphics g = getGraphics();
while (isPlay == true) {

input();
drawScreen(g);
try { Thread.sleep(delay); }
catch (InterruptedException ie) {}
}
}

// Method to Handle User Inputs
private void input() {
int keyStates = getKeyStates();

sprite.setFrame(0);

// Left
if ((keyStates & LEFT_PRESSED) != 0) {
currentX = Math.max(0, currentX - 1);
sprite.setFrame(1);
}

// Right
if ((keyStates & RIGHT_PRESSED) !=0 )
if ( currentX + 5 < width) {
currentX = Math.min(width, currentX + 1);
sprite.setFrame(3);
}

// Up
if ((keyStates & UP_PRESSED) != 0) {
currentY = Math.max(0, currentY - 1);
sprite.setFrame(2);
}

// Down
if ((keyStates & DOWN_PRESSED) !=0)
if ( currentY + 10 < height) {
currentY = Math.min(height, currentY + 1);
sprite.setFrame(4);
}
}

// Method to Display Graphics
private void drawScreen(Graphics g) {
//g.setColor(0xffffff);
g.setColor(0xFF0000);
g.fillRect(0, 0, getWidth(), getHeight());
g.setColor(0x0000ff);

// display sprites
sprite.setPosition(currentX,currentY);
sprite.paint(g);
nonTransparentSprite.paint(g);

flushGraphics();
}

}
   <<Less

Re: ALERT: java/lang/ClassFormatError: Bad version information.

Posted By:   Anonymous  
Posted On:   Monday, March 30, 2009 07:12 AM

Thanks guys. I have eventually found the problem is the IntelliJ actually caching the setting. It works fine with jdk1.3 after I rebuilt the project from scratch again.

Re: ALERT: java/lang/ClassFormatError: Bad version information.

Posted By:   Anonymous  
Posted On:   Monday, March 23, 2009 04:46 AM

Hi Hongliang Li,
I have tried your code and i found there are few mistake so i correct it and it;s working just check it i paste my code here and if any problem then reply me.




package hongliang;


import javax.microedition.midlet.*;

import javax.microedition.lcdui.*;


public class ExampleGameSpriteMidlet extends MIDlet

{

private Display display;


public void startApp()

{

try {

display = Display.getDisplay(this);


ExampleGameCanvas gameCanvas = new ExampleGameCanvas();


gameCanvas.start();


display.setCurrent(gameCanvas);


} catch (Exception ex) {


System.out.println(ex);

}

}


public Display getDisplay()

{

return display;

}


public void pauseApp()

{

}


public void destroyApp(boolean unconditional)

{

exit();

}


public void exit()

{

System.gc();

destroyApp(false);

notifyDestroyed();

}

}








import javax.microedition.lcdui.*;

import javax.microedition.lcdui.game.*;


public class ExampleGameCanvas extends GameCanvas implements Runnable

{

private boolean isPlay; // Game Loop runs when isPlay is true

private long delay; // To give thread consistency

private int currentX, currentY; // To hold current position of the 'X'

private int width; // To hold screen width

private int height; // To hold screen height


// Sprites to be used

private Sprite sprite;

private Sprite nonTransparentSprite;


// Constructor and initialization
public ExampleGameCanvas() throws Exception

{

super(true);

width = getWidth();

height = getHeight();

currentX = width / 2;

currentY = height / 2;

delay = 20;


// Load Images to Sprites
Image image = Image.createImage("/bt2.gif");

sprite = new Sprite (image,image.getWidth(),image.getHeight());


Image imageTemp = Image.createImage("/gprs2.gif");

nonTransparentSprite = new Sprite
(imageTemp,imageTemp.getWidth(),imageTemp.getHeight());



}

// Automatically start thread for game loop
public void start()

{

isPlay = true;

Thread t = new Thread(this);

t.start();

}


public void stop() { isPlay = false; }


// Main Game Loop
public void run()

{

Graphics g = getGraphics();

while (isPlay == true)

{


input();

drawScreen(g);

try { Thread.sleep(delay); }

catch (InterruptedException ie) {}

}

}


// Method to Handle User Inputs
private void input() {

int keyStates = getKeyStates();




// Left
if ((keyStates & LEFT_PRESSED) != 0)

{

currentX = Math.max(0, currentX - 1);

sprite.setFrame(0);

}


// Right
if ((keyStates & RIGHT_PRESSED) !=0 )

if ( currentX + 5 < width)

{


currentX = Math.min(width, currentX + 1);

sprite.setFrame(0);


}


// Up
if ((keyStates & UP_PRESSED) != 0)

{

currentY = Math.max(0, currentY - 1);

sprite.setFrame(0);

}


// Down
if ((keyStates & DOWN_PRESSED) !=0)

if ( currentY + 10 < height)

{

currentY = Math.min(height, currentY + 1);

sprite.setFrame(0);

}

}


// Method to Display Graphics
private void drawScreen(Graphics g) {

//g.setColor(0xffffff);

g.setColor(0xFF0000);

g.fillRect(0, 0, getWidth(), getHeight());

g.setColor(0x0000ff);


// display sprites
sprite.setPosition(currentX,currentY);

sprite.paint(g);

nonTransparentSprite.paint(g);


flushGraphics();

}


}


Re: ALERT: java/lang/ClassFormatError: Bad version information.

Posted By:   Anonymous  
Posted On:   Wednesday, March 18, 2009 07:38 AM

Hi,

Try to change your MIDP and CLDC version once.

It is sure JDK1.5 and higher version supports J2ME.

Regards,
Piyush Dhamija
About | Sitemap | Contact