Jump to content
  • Advertisement
Sign in to follow this  
maximuz_2

[java] Nullpointer exception j2me

This topic is 4741 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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...

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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!!!

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
my project structure is:



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

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!