I am experimenting with packages in Java using the Certification book examples. I tried to expand to use a package. I have two classes, LovePotion and DummyClass. Without the Java package line of: package com.group1;, LovePotion executes properly and creates the DummyClass object. No matter what combination of package lines I try to implement, I get error messages, such as: Class com.group1.DummyClass not found. The source code for DummyClass.java compiled without problems, but LovePotion.java had the error. What am I doing wrong? Remember, that without the package line, the code works. Code is below:
package com.group1;
public class DummyClass
{
public DummyClass()
{
System.out.println("Enter DummyClass Constructor"
}// end of DummyClass constructor
public static void main(String args[])
{
System.out.println("Entered DummyClass"
}
}// end of DummyClass
package com.group1;
public class LovePotion
{
LovePotion()
{
System.out.println("Enter LovePotion constructor"
}// end of LovePotion method
public static void main(String args[])
{
LovePotion lp = new LovePotion();
System.out.println("Love Potion in com.group1"
DummyClass dc = new DummyClass();
}// end of main method
}// end of class
package com.group1;
public class DummyClass
{
public DummyClass()
{
System.out.println("Enter DummyClass Constructor"
}// end of DummyClass constructor
public static void main(String args[])
{
System.out.println("Entered DummyClass"
}
}// end of DummyClass
package com.group1;
public class LovePotion
{
LovePotion()
{
System.out.println("Enter LovePotion constructor"
}// end of LovePotion method
public static void main(String args[])
{
LovePotion lp = new LovePotion();
System.out.println("Love Potion in com.group1"
DummyClass dc = new DummyClass();
}// end of main method
}// end of class