This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma 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

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.

Have you checked out Aspose?
subject: package statement
It's not a secret anymore!