[java] Nullpointer exception j2me

Started by
11 comments, last by maximuz_2 18 years, 5 months ago
hi guys first of all thanx for the response to my earlier posting(sokobanj2meNullpointexceception) .... really....especially Optus.. with ur help i seem to figure out that the nullpointer exception is all about the NULL reference to resource files like png images.. i got no error abt nullpointers in the ktoolbar of wireless tool kit...In it the images are to be pasted in the folder 'res' and can be accessed eg: createImage("/1.png") . but in jbuilder i dont know where to paste the image files and hence i get the nullpointer exception.ie i dont know how to get my resource files into the project workspace!!.So those who have used jbuilder plzz help me on this.. as i miss the on the spot error notification of jbuilder (which is so helpfull) in the wireless tool kit which is very raw for a beginner...
Advertisement
Taken from http://info.borland.com/techpubs/jbuilder/jbuilder9/introjb/projects_in_jbuilder.html:

Quote:Adding files to a project

JBuilder will use its automatic source path discovery feature and automatically add the folders and files that are in your project's source directory, if any exist. (You can turn this feature off, if you wish; see "Automatic source packages" for more information.)

If the automatic source path discovery feature is off, add files and packages to a new project by following these steps:

1. Click the Add Files/Packages/Classes button on the project pane toolbar or right-click the project file node in the project pane and choose Add Files/Packages/Classes from the context menu.

The Add Files Or Packages To Project dialog box appears.
2. Select either the Explorer page to add a file or the Packages page to add a package.

3. Navigate to the file or package you want to import and select it. You can Shift+click or Ctrl+click to select multiple file names.

4. Click OK.

The new package or file appears as a node in the project pane.
i tried it but then how do i refer to my image?? i added 1.png as u said and i could see it in my project tree... but when i use createImage("/1.png"), i get nullpointer exception!!!
Try leaving out the slash, because java might be misinterpreting the slash as the root directory. If that doesn't work, supply a full path to the image, such as C:\my projects\game\1.png
nope!! i tried both ,... still i get the error!!!! its abt jbuilder . plz note that i had no error for the same statement in wireless toolkit.
It's been awhile since I even looked at JBuilder, but perhaps resource files need to be placed within a particular project folder in order to go into /res?
exactly.... thanx Sneftel... can anyone be more specific?
"draw" for us the structure of your project.

And try loading the image using "./file.png"
a.k.a javabeats at yahoo.ca
my project structure is:



tiletrial.jpx
.
.---<Project Source>
. .
. .---Screen.java
. .
. .---Tile.java
.
.--1.png
i tried "./1.png" but dint work
Hi guys,

Im having the same problem, but with the Toolkit, and Netbeans. Man this is frustrating... nullpointer ... such a simple thing.

can it maybe have something to do with creating a package?

This topic is closed to new replies.

Advertisement