I imported a jar package in the external libraries directory.Under the src directory, Test1 can reference classes from HelloJava.jar package and successfully run , but Test2 which in the subdirectory(com.cau) can not.
As the following pictures show:
Test1 code is:
public class Test1 {
public static void main(String[] args) {
Puppy MyPuppy = new Puppy("Jerry");
MyPuppy.setPuppyAge(2);
MyPuppy.getAge();
}
}
Test2 code is:
package com.cau;
public class Test2 {
public static void main(String[] args) {
Puppy MyPuppy = new Puppy("Jerry");
MyPuppy.setPuppyAge(2);
MyPuppy.getAge();
System.out.println("123456");
}
}
The class Puppy is in HelloJava.jar package. In the third picture, the red color "Puppy" means Test2 was failed to reference HelloJava.jar.
I am searching for a long time on net. But no use. Please help or try to give some ideas how to achieve this.