• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

symbol not found error

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a small exercise consisting of a person as one class who has arms, legs and a head, each as a separate class. The person is built up of the other classes.

Each of the classes - arm, leg and head - complies separately but when it comes to Human, I get lots of symbol not found errors.

The human contains the correct constructors (as far as I can see) and the classes are all in the same package so what is up?

I have looked up this error on the Sun forum and someone there posted something similar. Turned out to be a classpath issue as he had recently installed Quicktime. I have checked my classpath and it SEEMS fine (to a novice like me).

Anything I can do to make sure that my person finds his limbs?

K
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you post your code?
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Things to check:

- Is your classpath set correctly?
- Are the classes that you reference present in the correct directory?
- Java is case sensitive; did you write names with a different case than they should be?
- Did you make a typo somewhere?
 
Ranch Hand
Posts: 320
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And make sure that you are calling constructors/methods that have a matching signature..... so that overloading isn't getting to you unexpectedly. (i.e. if you define a method with a particular set of arguments and then call it with one of the arguments of the wrong type, it will complain that symbol can not be found because it can't find the method name with the combination of arguments that you specified on the call.
 
Keith Stansbie
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Before the code, firstly, thanks for all of the prompt replies.

Next, I reckon that my classpath is correct. Path points to the only place I keep code and classpath is to the version of java I am using.

Firstly, arm:

/**
*Author Keith Stansbie
*A simple class to make arms for the human
**/
import java.util.*;

public class Arm{
boolean side; //true is right, false is left
int nailLength; //length of nails
boolean tan; //is arm tanned?

protected Arm(boolean side, int nailLength, boolean tan){
this.side = side;
this.nailLength = nailLength;
this.tan = tan;
}

//Method to grow nails

public void nailgrow(){
nailLength++;
}
}

Next, leg:

/**
*Author Keith Stansbie
*A simple class to make legs for the human
**/

import java.util.*;

public class Leg{
boolean side; //true is right, false is left
int location; //position of leg
int length; //length of leg

protected Leg(boolean side, int location, int length){
this.side = side;
this.location = location;
this.length = length;
}

//Method to move leg

public void move(){
location++;
}
}

Now a head:

/**
* @author Keith Stansbie
* A simple class to make a new head for the humam
**/

import java.util.*;

public class Head{
String eyeColour;
String hairColour;
boolean piercedEar;

/**
* @param EyeColour the colour of the eyes.
* @param HairColour the colour of the hair.
* @param Set piercedEar to true or false.
**/

protected Head(String eyeColour, String hairColour, boolean piercedEar){
this.eyeColour = eyeColour;
this.hairColour = hairColour;
this.piercedEar = piercedEar;
}
}

And this is the Human:

/**
* A simple class to make a human
*@author Keith Stansbie
**/

import java.util.*;
import java.io.*;

public class Human{
public Head head;
public Arm rightArm;
public Arm leftArm;
public Leg rightLeg;
public Leg leftLeg;

public Human(Head myHead, Arm myLeftArm, Arm myRightArm, Leg myLeftLeg, Leg myRightLeg){
this.head = myHead;
this.rightArm = myRightArm;
this.leftArm = myLeftArm;
this.leftLeg = myLeftLeg;
this.rightLeg = myRightLeg;
}

public void walk(int step){
for(int j=0; j<=step; j++){
// Call the move method from the Leg class.
leftLeg.move();
rightLeg.move();
}
}

public static void main(String[] args){
/**
* This makes new arms,legs and head classes
**/
Head myHead = new Head("Blue","Grey",true);
Arm myLeftArm = new Arm(true,6,false);
Arm myRightArm = new Arm(true,6,false);
Leg myLeftLeg = new Leg(false,0,9);
Leg myRightLeg = new Leg(false,0,9);
/**
* Make a new Human Class and add the arms,legs,and head object
* to the human class
**/
Human me = new Human(myHead,myLeftArm,myRightArm,myLeftLeg,myRightLeg);
}
}

All 4 classes are in the same package inside the folder where I keep my code. I have tried with the package statement at the start of each to no effect. I have checked the filename of each class and they are Leg, Arm, Head (all of which compile, BTW) and Human. All.java and all capitalised.

Sorry if the formatting is mucked up with the copy/paste.

Also apologies for the long post - but i was asked for the code

FWIW, I think that it is one of those glaringly ridiculous errors that only one who has spent days looking (as I have) could possibly miss

K
 
Ranch Hand
Posts: 209
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Keith Stansbie,
First of all, you can enclose your code within code tags to preserve your formatting.
Secondly, I copied-pasted all your programs and did NOT get any compile errors. I did not specify any package names to avoid package-related hassles.
So, if you are using packages, then there might be something you might be missing over there.
Thirdly, you mentioned:


Next, I reckon that my classpath is correct. Path points to the only place I keep code and classpath is to the version of java I am using.



Shouldn't that be the other way round? Path should be pointing to your Java version and classpath to your source files. I may be wrong. But on my machine Path is set to my Java version.

Fourthly, please do post the compile errors that you are getting.

Note: While posting a message, you will see Instant UBB Code tags listed below the Text Area. You can select the Code tag to enclose your code.
 
Keith Stansbie
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If there was a smiley for a red face, I would post it.

Yes, the path is Java version - sorry for the error.

Otherwise, it is still giving me the symbol not found.

K
 
Keith Stansbie
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


This is the first of the errors. I get 20 in total

K
 
Bob Ruth
Ranch Hand
Posts: 320
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I built it and ran it with no problems too. I even made it walk.
 
Keith Stansbie
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am very happy to hear it!

I would love to know why it doesn't for me

Thanks for all the replies.

K
reply
    Bookmark Topic Watch Topic
  • New Topic