Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

package statement

 
Venkatesh Kumar
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All:

I am trying to compile two classes with the package statement and am getting compiler errors --cannot resolve symbol class name.I have placed both the programs in the following dir path E:\parent\child and am trying to compile after navigating to child directory...Can anyone please let me know where I am going wrong???

classOne --
package parent.Child;
public class classOne {
public static void main(String args[])
{
classTwo d = new classTwo();
classTwo ds=new classTwo("Hello");
d.PrintMe();
}
}

classTwo---------
package parent.Child;
public class classTwo{
public classTwo(){}

public classTwo(String s){
System.out.println("From ClassTwo--"+s);
}
public void PrintMe(){
System.out.println("From Method--Hello");
}
}

Thanks
 
Julian Kennedy
Ranch Hand
Posts: 823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to ensure that the %classpath% environment variable contains ".", the current directory. You can do this using "set classpath=.;%classpath%"

Also note that conventionally package names are all lower case, so it would be parent.child, not parent.Child and class names are title case so it would be ClassOne and ClassTwo, not classOne and classTwo. Variable and method names have the style methodName and variableName.

When posting code you can preserve your formatting by wrapping the code in the UBB [code] and [/code] tags.

Hope that helps.

Jules
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic