You Are Here:

Community: Developer Discussion Boards

#1 Old Unable to load files into MIDP default phone - 2003-03-03, 18:49

Join Date: Mar 2003
Posts: 1
alan_stewart
Offline
Registered User
Hello! I've just started getting into wireless games Java programming and have been doing a lot of poking around on the web to find out all about it. And there's a lot there! I have downloaded the tools needed and have gotten a couple of sample MIDlet's to work. I've also taken the sample code from the "Your First Micro Java Game" article (class SpaceGame) at <http://www.onjava.com/lpt/a/2945> and have managed to get it to compile and run. However, I have run into a problem and I was wondering if by any chance anyone else had encountered this in any of thair Micro Java work. I am having troubles getting midp to load up *any* files (such as ship.png) from the disk. I always get "Problem loading image java.io.IOException". However, if I make everything into a .JAR file and run it with midp then things work just fine and the little rocket ship shows up.

Needless to say this is very frustrating. I've tried searching the web but haven't found any help there yet. I am running Windows '95 but I don't *think* that's the problem. I'm not using any IDE's, just writing the code into my text editor (Zeus) and then compiling, preverifying, and running from a DOS window.

java version "1.4.1_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_01-b01)
Java HotSpot(TM) Client VM (build 1.4.1_01-b01, mixed mode)

midp -version
Profile Spec : MIDP-1.0
Profile Impl : 1.0.3 dist
Configuration: CLDC-1.0

Here are the batch files that I'm using:

M.BAT - To make and preverify. Use "m j" to make the .JAR file:
-----
@ECHO OFF

IF "%1" == "" GOTO Build
IF "%1" == "j" GOTO MakeJar

:Build
del classes\*.class
del verified\*.class
ECHO Compiling ...
javac -g -verbose -target 1.1 -d .\classes -bootclasspath C:\J2SDK\MIDP\CLASSES -deprecation *.java
ECHO Preverifying ...
preverify -cldc -classpath C:\J2SDK\MIDP\CLASSES -d .\verified .\classes
GOTO End

:MakeJar
ECHO Making ...
CALL M.BAT
ECHO Jarring ...
jar cvfm SpaceGame.jar manifest.mf *.png -C .\verified .

:End

----------

P.BAT - To run/play the MIDlet/game. Use "p j" to play from the .JAR file:
-----
@ECHO OFF

IF "%1" == "j" GOTO Jar

midp -classpath .\verified SpaceGame
GOTO End

:Jar
midp -classpath SpaceGame.jar -descriptor SpaceGame.jad

:End
----------

And here's the .JAD file:
-----
MIDlet-1: Space Game,, SpaceGame
MIDlet-Jar-Size:
MIDlet-Jar-URL: SpaceGame.jar
MIDlet-Name: Space Game MIDlet Example
MIDlet-Vendor: David Fox
MIDlet-Version: 1.0

----------

I'm going to find some other MIDlet examples that load files and see if I can get them to work but thought I'd drop a line and see if maybe I'm not the only person to have encountered this.

Thank you so much!
Alan Stewart
astewart AT direct DOT ca
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules

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

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Forum Jump

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia