vaishnavi
05-26-2009, 11:17 AM
Hi,
I am struggling a lot to compile a program which involves package. I am trying to learn this, but getting errors
Here is my first program:
package sun1;
public class packageConcept
{
public enum Color { RED, GREEN, BLUE }
public static void main(String args[])
{
System.out.println("hi");
}
}
I have placed the above code inside a folder called sun1 and named it as 'packageConcept.java'. I compiled using javac, went up one level and executed with java sun1.packageConcept.
It executed fine, and gave the output "hi".
My second program:
package beta;
import sun1.packageConcept;
import static sun1.packageConcept.*;
public class Beta {
packageConcept.Color g = GREEN;
public static void main( String[] argv)
{ System.out.println( GREEN); }
}
I placed the above program in a folder named 'beta' and name the file as Beta.java. When i tried to compile with javac Beta.java, I got the following errors:
package sun1 does not exist
import sun1.packageConcept
I am struggling a lot to compile a program which involves package. I am trying to learn this, but getting errors
Here is my first program:
package sun1;
public class packageConcept
{
public enum Color { RED, GREEN, BLUE }
public static void main(String args[])
{
System.out.println("hi");
}
}
I have placed the above code inside a folder called sun1 and named it as 'packageConcept.java'. I compiled using javac, went up one level and executed with java sun1.packageConcept.
It executed fine, and gave the output "hi".
My second program:
package beta;
import sun1.packageConcept;
import static sun1.packageConcept.*;
public class Beta {
packageConcept.Color g = GREEN;
public static void main( String[] argv)
{ System.out.println( GREEN); }
}
I placed the above program in a folder named 'beta' and name the file as Beta.java. When i tried to compile with javac Beta.java, I got the following errors:
package sun1 does not exist
import sun1.packageConcept