GeeCON Prague 2014*
The moose likes Beginning Java and the fly likes package statement Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "package statement" Watch "package statement" New topic
Author

package statement

Venkatesh Kumar
Ranch Hand

Joined: Aug 08, 2003
Posts: 68
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

Joined: Aug 02, 2004
Posts: 823
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
 
GeeCON Prague 2014
 
subject: package statement