| Reply | « Previous Thread | Next Thread » |
|
my development environment is Jbuilder9 + nokia developer suite2.0¡£I made some files(like a.1, a.2) by notebook,I want to read these files on jb9,but failure:
my code is: InputStream is = getClass.getResourceAsStream("a.1") but the error is: NullPointerException i guess that the path is incorrect. the "a.1" file is at %ProjectName%/src/a.1 my english is poor,i hope i described expressly¡£thank you! |
|
I guess your this pointer is null. Do you try this code from within a static method?
Also check that your a.1 file is actually put into JAR file. JBuilder archives automatically only *.png files |
|
use a / before the file-names.
and as stated make sure the files are copied into the classes folder (project-properties - build - resource) and add the extensions to the 'copied' files. |
|
my path is:
"HealthVegetables" is my project name. and all the file is at the directory of "HealthVegetables". HealthVegetables---->src HealthVegetables---->res HealthVegetables---->class HealthVegetables---->temp-jad HealthVegetables---->bak i put the "a.1" in the directory "res". At the Jb9, "project"---->"project properties"---->"Source"---->"Add", and then selecting the directory "res" ---> "OK" |
|
"PushPuzzle" game sample is at J2meWTK, it is successful to read the outer file.
if you use jb9 , you can open the project file(game.jpx) at "JBuilder9\j2mewtk1.0.4\apps\games", it has a PushPuzzleCanvas.java at "PushPuzzle "package, at line 264. |
|
a sample:
$workDirectory/src/res/conf.txt InputStream in = getClass().getResourceAsStream( "/res/conf.txt"); it works well. |
| cn.dog.blackdog |
| View Public Profile |
| Find all posts by cn.dog.blackdog |
|
D:\JBuilder9\j2mewtk1.0.4\bin\emulator.exe -classpath "D:\JBuilder9\j2mewtk1.0.4\apps\games\classes;" -Xdevice:DefaultColorPhone -Xdescriptor:"D:\JBuilder9\j2mewtk1.0.4\apps\games\jad-temp\PushPuzzle.jad"
Could not find the game board for level 1 Execution completed successfully 68917 bytecodes executed 23 thread switches 326 classes in the system (including system classes) 1381 dynamic objects allocated (56212 bytes) 13 garbage collections (35852 bytes collected) Total heap size 500000 bytes (currently 459160 bytes free) |
| cn.dog.blackdog |
| View Public Profile |
| Find all posts by cn.dog.blackdog |
|
koolgi
Knowing your project settings might help you find the workaround, but does not really help to identify the problem. Check whether your file is actually put to the JAR file and that it is at the expected path. As far as I know JBuilder can also run projects without packaging JAR, but using "classes" directory (if emulator supports this). If you use this way, check that your file is copied to the "classes" dir and to the appropriate subdirectory |
|
rename the file *.* to *.properties, the JB9 can recognise the files, you can read the outer files.
to : cn.dog.blackdog the jbuilder can not run the PushPuzzle Game in game.jpx, because jb9 donot recognise the file like screen.1, but if you use Sun J2meWTK's simulator ,the game will be run normally! In the end, thank you everyone who helped me, let's to share it :-) |
| Reply | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|