Jump to content

  • Log In with Google      Sign In   
  • Create Account

cannot find symbol even though its defined

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1   Members   -  Reputation: 1459


Posted 20 May 2013 - 07:53 PM

Hello folks. It has been a while since I posted on the forums.


I've revived a project from ages ago, and I've been going through the source trying to get the thing to work. I'm getting the following errors:


E:\NetBeansProjects\Digestion\src\Entity\Entity.java:164: error: cannot find symbol
  symbol:   method resetTimer()
  location: variable mMotionModule of type MotionModule
E:\NetBeansProjects\Digestion\src\Entity\Entity.java:173: error: cannot find symbol
			mMotionModule.update(this, manager.getEntities());
  symbol:   method update(Entity,LinkedList<Entity>)
  location: variable mMotionModule of type MotionModule
E:\NetBeansProjects\Digestion\src\Entity\Entity.java:176: error: cannot find symbol
  symbol:   method update()
  location: variable mPathfindingModule of type PathfindingModule
E:\NetBeansProjects\Digestion\src\Entity\Entity.java:189: error: cannot find symbol
  symbol:   method draw(GameCanvas)
  location: variable mHealthModule of type HealthModule
4 errors
E:\NetBeansProjects\Digestion\nbproject\build-impl.xml:605: The following error occurred while executing this line:
E:\NetBeansProjects\Digestion\nbproject\build-impl.xml:246: Compile failed; see the compiler error output for details.
BUILD FAILED (total time: 0 seconds)


I thought this was a rather routine error: I probably just misspelled a few function names. The thing is though, I haven't. To make extra sure, I copied and pasted them into place but the compiler still gives me those errors. Even more strange, NetBeans' error highlighter does not mark these lines as errors. Only the compiler. 


Here is the Entity class (errors are marked with line comments)

package Entity;

import java.awt.geom.Rectangle2D;

import Core.Level.Level;
import Core.Messages.Message;
import Core.Messages.MessageQueue;
import Entity.EntityScripting.EntityScript;
import Entity.Modules.*;
import Graphics.GameCanvas;

public class Entity {
	private String mName;
	private Rectangle2D.Float mBoundRect;
	private int mDepth;
	private Level mLevel;
	private String m_pwd;
	private EntityScript mObjectScript;

	private HealthModule mHealthModule;
	private MotionModule mMotionModule;
	private GraphicsModule mGraphicsModule;
	private SoundModule mSoundModule;
	private PathfindingModule mPathfindingModule;
	private MessageQueue mMessageQueue;

	public Entity(Level level) {
		mLevel = level;
		mName = "Default";
		mBoundRect = new Rectangle2D.Float(0, 0, 0, 0);
		m_pwd = null;  
		mObjectScript = null;
		mHealthModule = null;
		mMotionModule = null;
		mGraphicsModule = null;
		mPathfindingModule = null;
		mSoundModule = null;
		mMessageQueue = new MessageQueue();

	public boolean initialize(String pwd, EntityScript objectScript, int x, int y, String[] arguments) {
		m_pwd = pwd;
		mObjectScript = objectScript;
		mBoundRect.x = x;
		mBoundRect.y = y;
		mObjectScript.create(this, arguments);
		return true;
        // ...
        // Snip unrelated functions
        // ...

	public void reset() {
		if(mMotionModule != null)
			mMotionModule.resetTimer();                        // Error occurs here
	public void update(EntityManager manager) {
		if(mMotionModule != null)
			mMotionModule.update(this, manager.getEntities()); // Error occurs here
		if(mPathfindingModule != null)
			mPathfindingModule.update();                       // Error occurs here
	public void draw(GameCanvas canvas) {
		if(mGraphicsModule != null) {
		if(mHealthModule != null) {
			mHealthModule.draw(canvas);                        // Error occurs here



and the MotionModule class (the error is the same for the other two classes featuring different functions)


package Entity.Modules;

import java.awt.geom.*;
import java.util.LinkedList;

import Entity.Entity;
import Util.GameTimer;
import Util.Vector2D;

public class MotionModule {
	private static class Force	{
		String name;
		Vector2D force;
		public Force(String name, Vector2D force) {
			this.name = name;
			this.force = force;

	private double mMass;
	private Vector2D mVelocity;
	private double mTerminalVelocity;
	private LinkedList<Force> mForces;
	private Vector2D mJumpForce;
	private boolean mJump;
	private boolean mCanJump;
	private boolean mCanDoubleJump;
	private boolean mDoubleJumpFlag;
	private boolean mStopOnSolid;
	private double mGravity;
	private GameTimer mTimer;
	public MotionModule(double mass, double terminalVelocity) {
		mMass = mass;
		mVelocity = new Vector2D(0.0f, 0.0f);
		mTerminalVelocity = terminalVelocity;
		mForces = new LinkedList<Force>();
		mJumpForce = new Vector2D(0.0, 0.0);
		mJump = false;
		mDoubleJumpFlag = false;
		mStopOnSolid = false;
		mGravity = 0.0;
		mTimer = new GameTimer();

        // ...
        // Snip unrelated functions
        // ...

	public void resetTimer() {
	public void update(Entity entity, LinkedList<Entity> entityList) {
		// Elapsed time in seconds
		double elapsedTime = getTimeStep();
		Rectangle2D.Float entRect = entity.getObjectRect();
		// Move forward //
		Vector2D deltaPos = integrateVelocity(elapsedTime);
		entRect.x += deltaPos.x;
		entRect.y += deltaPos.y;
		// Check collision //
		Entity obstacle = null;
		boolean collisionFree = false;
		while(!collisionFree) {
			for(Entity worldEntity: entityList) {

				Rectangle2D.Float obstRect = worldEntity.getObjectRect();

				Vector2D entCenter = new Vector2D(entRect.x + entRect.width/2, entRect.y + entRect.height/2);
				Vector2D obstCenter = new Vector2D(obstRect.x + obstRect.width/2, obstRect.y + obstRect.height/2);

				Vector2D obstClosestCorner = closestCornerToCenter(entCenter, obstRect);
				Vector2D entClosestCorner = closestCornerToCenter(obstCenter, entRect);

				Vector2D posShift = obstClosestCorner.subtract(entClosestCorner).projectOn(deltaPos);

				entClosestCorner = entClosestCorner.subtract(posShift);

				Vector2D collisionNormal = getCollisionNormal(entClosestCorner, obstClosestCorner, deltaPos);

				entRect.x -= posShift.x;
				entRect.y -= posShift.y;
			collisionFree = true;



The package hierarchy is as follows <src>/Entity/Modules

The Entity class resides in package Entity, whereas all the Modules reside in Entity/Modules


Does anyone have any idea as to why I'm getting this seemingly baseless error? Some folks said it has to do with classpaths. I looked through the project properties but I have not found anything that might cause this.

My personal links
- Khan Academy - For all your math needs
- Java API Documentation - For all your Java info needs
- C++ Standard Library Reference - For some of your C++ needs ^.^

#2   Moderators   -  Reputation: 8558


Posted 21 May 2013 - 08:24 AM

Everything looks right.  If there is some simple typo or something, then don't feel bad because I don't see it either.  If I had to guess then there is a problem with the packages.  Maybe the folders are all lower case and don't start with a capital letter?  


Packages names and folders are all lower case by convention, but I do not know if Java actually cares.  I've never even tried.  If I were you, I would start a new project and create example files with the same packages names and see if that works.

I think, therefore I am. I think? - "George Carlin"
My Website: Indie Game Programming

My Twitter: https://twitter.com/indieprogram

My Book: http://amzn.com/1305076532

#3   Members   -  Reputation: 1459


Posted 21 May 2013 - 10:58 AM

I had a feeling that it wasn't the code that was generating the error, and it seems I was right. To be extra sure I wasn't going crazy, I compiled the code manually via command line last night and it compiled without problem. To fix the problem, I copied all of the source code, deleted the project in NetBeans, created a new one, and pasted the source back into the right folder. Then NetBeans was able to compiled the source without goofy errors. I intended to post the fix yesterday night but for some reason I was not able to log in, so I'm only able to post the update today.

My personal links
- Khan Academy - For all your math needs
- Java API Documentation - For all your Java info needs
- C++ Standard Library Reference - For some of your C++ needs ^.^

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.