Hi Team,
I have two java Files
Print (Package A)
Apple (Package B.C) (Jave file is inside C:\Z\A\B\C\
I have compiled and kept Print.class file inside C:\Z\A\B\A\
Now i have made a Jar file of Print.class named MyJar.jar and kept it in Z\A\
When i try to compile Apple which needs Print class Method, It throws error.
The Program and error or below . Please advice.
C:\Z>javac -cp a/b/MyJar.jar -d A\ A\b\c\Apple.java
A\b\c\Apple.java:3: error: package A does not exist
import A.*;
^
A\b\c\Apple.java:10: error: cannot find symbol
Print obj = new Print();
^
symbol: class Print
location: class Apple
A\b\c\Apple.java:10: error: cannot find symbol
Print obj = new Print();
^
symbol: class Print
location: class Apple
3 errors
package B.C;
import A.*;
public class Apple {
public static void main(String[] sam) {
Print obj = new Print();
obj.print();
}
}
package A;
public class Print {
public void print() {
System.out.println("Printing the output");
}
}
** Command i used to create jar file is below **
C:\Z>jar -cf A\MyJar.jar A\B\
C:\Z>jar -tf A\Myjar.jar
META-INF/
META-INF/MANIFEST.MF
A/B/
A/B/A/
A/B/A/MyJar.jar
A/B/A/Print.class
A/B/C/
A/B/C/Apple.class
A/B/C/Apple.java
A/B/C/Orange.class
A/B/C/Orange.java
A/B/Orange.class
A/B/Orange.java