This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
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


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: package statement