Problem With Initializing JBox2D World

Discuss issues specific the Java port of Box2D
mohsen
Posts: 4
Joined: Mon Apr 01, 2013 2:40 am

Problem With Initializing JBox2D World

Postby mohsen » Mon Apr 01, 2013 3:30 am

Hi Everyone.
We are a team working on a game for Android. We are using JBox2D with Eclipse but the problem is that every time after run the project as Android Application, the Eclipse logs out errors such as "Could not find class 'org.jbox2d.dynamics.World' reference however, we are sure that we have included the external jar file jbox2d-library-2.1.2.3-jar-with-dependencies.jar in the Build Path of the project.

We have tracked the issue and we have found out that the error is reported whenever the World object is initialized.

We have a private World object:

private World m_World;

and in the constructor of the class we initialize it:

m_World = new World(new Vec2(0, -9.8f), false);

Does anyone have any idea what the problem is?
Thanks in advance.

toucansam
Posts: 356
Joined: Mon Jun 08, 2009 12:21 pm
Contact:

Re: Problem With Initializing JBox2D World

Postby toucansam » Wed Apr 10, 2013 11:24 pm

Are you sure you're calling a constructor that exists?

mohsen
Posts: 4
Joined: Mon Apr 01, 2013 2:40 am

Re: Problem With Initializing JBox2D World

Postby mohsen » Thu Apr 11, 2013 8:22 am

Sorry what you mean by exists?

I should say that when I comment the line m_World = new World(new Vec2(0, -9.8f), false) and then build the project, the application which is going to be a game runs properly in my android phone. but when I uncomment that line, it crashes and says Unfortunately it has stopped.

so I thought the problem is in initializing the jbox2d world.

toucansam
Posts: 356
Joined: Mon Jun 08, 2009 12:21 pm
Contact:

Re: Problem With Initializing JBox2D World

Postby toucansam » Thu Apr 11, 2013 11:11 am

Whoops, I thought you were using the newer version of the engine, where that constructor does not exist.

mohsen wrote:but when I uncomment that line, it crashes and says Unfortunately it has stopped.


I need a little more information, I have no idea what is going wrong. :(

mohsen
Posts: 4
Joined: Mon Apr 01, 2013 2:40 am

Re: Problem With Initializing JBox2D World

Postby mohsen » Fri Apr 12, 2013 1:25 am

Sorry for not being so clear

this is a part of my PhysicsScene class

Code: Select all

public class CPhysicsScene {
   private World m_World;
   
   CPhysicsScene()
   {
      m_World = new World(new Vec2(0, -9.8f), false);
   }

        ...
}


when I connect my phone to my PC via a USB cable and in Eclipse run the project as Android Application, on my Phone it crashes and say Unfortunately it has stopped however, when I comment the line for creating a new World and run the project as Android application, it runs properly.

Code: Select all

public class CPhysicsScene {
   private World m_World;
   
   CPhysicsScene()
   {
      //m_World = new World(new Vec2(0, -9.8f), false);
   }

        ...
}


that is why I thought it has something to do with initializing the jbox2d World.

mohsen
Posts: 4
Joined: Mon Apr 01, 2013 2:40 am

Re: Problem With Initializing JBox2D World

Postby mohsen » Tue Apr 30, 2013 2:47 am

Problem solved using the library source files instead of the jar one.

bmd007
Posts: 1
Joined: Thu Oct 16, 2014 10:58 pm

Re: Problem With Initializing JBox2D World

Postby bmd007 » Thu Oct 16, 2014 11:01 pm

Hello

I have same problem

how can i do this:
Problem solved using the library source files instead of the jar one.

How can i reach to library source


Return to “Java”



Who is online

Users browsing this forum: Google [Bot] and 2 guests