Java.lang.NullPointerException tring loading an obj

Here I am again. Now my problem is with .obj loading.

Using the code of the tutorial HelloModelLoading (which works and show me lisa perfectly) I've tried to load an obj that i've made with sketcUp Pro. The result is:

GRAVE: Exception in game loop


at primaProva.simpleInitGame(

at Source)

at Source)

at primaProva.main(

the source code is:

// Point to a URL of my model

        URL model = primaProva.class.getClassLoader().getResource("/provaJME/src/data/PianoTerra.obj");

        // Create something to convert .obj format to .jme

        FormatConverter converter = new ObjToJme();

        // Point the converter to where it will find the .mtl file from

        converter.setProperty("mtllib", model);

        // This byte array will hold my .jme file

        ByteArrayOutputStream BO = new ByteArrayOutputStream();

        try {

            // Use the format converter to convert .obj to .jme

            converter.convert(model.openStream(), BO);

            Node maggie = (Node) BinaryImporter.getInstance().load(new ByteArrayInputStream(BO.toByteArray()));

            // shrink this baby down some


            maggie.setModelBound(new BoundingSphere());


            // Put her on the scene graph


        } catch (IOException e) {  // Just in case anything happens

            System.out.println("Damn exceptions!" + e);




Debugging with eclipse i've found that the problem is that the following line of code:

URL model = primaProva.class.getClassLoader().getResource("/provaJME/src/data/PianoTerra.obj");

return null and so the conversione to jme fail for java.lang.NullPointerException.

I've tried changing the path and the folder of my obj but it still doesn't work.

Why it don't "catch" my obj??? What can i do???

Sorry for my bad English!!!

  1. welcome
  2. don't use multiple exclamation marks!  :wink:
  3. Class names always have to begin with an upper case letter in Java  :x (PrimaProva)
  4. try it with these paths:




    NOTE: none of them must have the slash at the beginning!

Thx for your help! Now it's working! Next time I'll not use multiple exclamation marks! For the upper case letter forgive me but I'm back to Java after a 5 month of C++!!  :smiley: