This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread 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 Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "package statement" Watch "package statement" New topic

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");

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");

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.

I agree. Here's the link:
subject: package statement
Similar Threads
Protected Behaviour
Passing a refrence to another Class vs method
Overriding : Why it is this ambiguous to compiler
About multiple inheritance in Java
OO doubt