Skip to main content
GameDev.net gamedev.net
🔒 Locked

Strange error

Started by Al Gorithm Jan 27, 2005 at 10:39 PM 9 replies 2.1k views
Original Post
Al Gorithm
Al Gorithm
I don't know if this is the right forum for this, but . . . I'm a C programmer who recently decided to try out the J2ME side of things. I hardly know Java or these libraries, and there's this bit of code that keeps turning up a problem. I'd been consulting the Wells book on J2ME game programming and used that code as a reference but couldn't see where my problem lay. Google didn't help either. So I'm asking someone here. The compiler keeps turning up a simple "error verifying class" The code causing the problems is public void run(){ StartTime = System.currentTimeMillis(); renderer.repaint(); //SNIP Timelapsed = System.currentTimeMillis() - StartTime; //The line below is the one that turns up the error if(Timelapsed < 20){ try{Thread.sleep(20-Timelapsed);} catch(java.lang.InterruptedException e){} } } //starttime and timelapsed are longs
Al Gorithm
Al Gorithm
No, I'm pretty sure I'm using MIDP 1

this line if(Timelapsed <= 20){
and a while(running) loop within

this class alone
class Renderer extends Canvas implements Runnable
cause the problem

i don't know if that helps

EDIT : I'm going to just code these things outside that class, but nonetheless I'm curious as to why it does not work within it
werekarg
werekarg
Quote:
The compiler keeps turning up a simple "error verifying class"


what compiler are you using? are you developing with an ide (jbuilder, jcreator, eclipse)? what j2me sdk are you using? the default one from sun or a custom one from a nokia-sonyericsson-whatever?

(it happened to me with sonyericsson sdk and jbuilder9 that compiling would result in an "error preverifing class")

Al Gorithm
Al Gorithm
Well, I decided it was time to change tools today to NetBeans IDE 4.0 today for various reasons, and everything much better now . . . except I get a nullpointer exception when i try to reference the image files in my application
eg : SplashScreen = Image.createImage("/splash.png");

when my renderer draws the splash screen for instance, it returns this :

java.lang.NullPointerException:
at Doggystyle$Renderer.SplashScreen(+18)
at Doggystyle.RunGame(+19)
at Doggystyle.NewGame(+102)
at Doggystyle$Renderer.paint(+19)
at javax.microedition.lcdui.Canvas.callPaint(+80)
at javax.microedition.lcdui.Display.repaint(+77)
at javax.microedition.lcdui.Display$DisplayAccessor.repaint(+14)
at javax.microedition.lcdui.Display$DisplayManagerImpl.repaint(+16)
at com.sun.midp.lcdui.DefaultEventHandler.repaintScreenEvent(+24)
at com.sun.midp.lcdui.DefaultEventHandler$QueuedEventHandler.run(+774)

Now, when I ported to netbeans I didn't change the code around at all, and the file's made its way into the jar file, so being the j2me/java newbie I am, I'm not sure what the problem is. However, I'm going to assume I don't have NetBeans set up properly to run my application. Is there some kind of application setting or parameter I'm missing out on? Any help you can give would be appreciated, so I can get the phone version of our nifty little sidescroller done instead of just a pc version.
Zahlman
Zahlman
First, manually verify the JAR contents (open it with WinRAR or something like that, and check that the appropriate .PNG is there, in the root directory).

Also make sure that the JAD references the correct JAR file (the JAD is plain-text and pretty easy to understand, so just check that everything looks logical).

If that checks out ok then you may well have a problem in the NetBeans configuration, yes.
Vex
Vex
Also it's case sensitive, so make sure the cases match.
Vex / Developer---------------Graphic RealityG4MES.netAvailable for freelance J2ME work.. :)
BitMaster
BitMaster
I'm not familiar with Java for mobiles, but wouldn't you have to use getResource or getResourceAsStream (and placing the png in a place relative to the class) to access the file?
Zahlman
Zahlman
To get access to files to read them as raw data, yes (getResourceAsStream); but the MIDP library also provides the 'createImage' factory method in class Image to open the file and use its data to construct a new Image object. [smile]
Al Gorithm
Al Gorithm
Thanks for your replies. However . . . I'm doing everything right and it's flat out not working. The file is even in the JAR. It's not able to load the image nonetheless. I can even use it as the MIDlet icon, but I can't access it from the MIDlet itself. Anyone have any advice besides "tough shit"?

EDIT : I decided to make my JADs and JARs by hand, using my old files with the command prompt and just give NETBEANS the finger. It works now. Thanks for your help.

[Edited by - Al Gorithm on February 10, 2005 3:32:29 PM]
Al Gorithm
Al Gorithm
EDIT : Never mind. Been staring at it for too long :)

[Edited by - Al Gorithm on February 10, 2005 6:24:05 PM]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.