Hi all. I’m studying Eckel, trying to figure out the compilation of packages, but the example in the book is described poorly, I haven’t found any good information on the Internet, so I ask the guru here to tell me what the problem is.
In general, there is an access folder, in it there is a file LibTest.java, its contents:
I tried compiling with different commands, for example Environment variables are set, path C:\Program Files is added for Path \Java\jdk1.7.0_60\bin, D:\Work\Java\stud is added for CLASSPATH What am I doing wrong, why does the compiler not pull up the package files, as I understand it, it should look for them in CLASSPATH?
In general, there is an access folder, in it there is a file LibTest.java, its contents:
//: access/LibTest.java // Uses the library. import net.mindview.simple.*; public class LibTest { public static void main(String[] args) { Vector v = new Vector(); List l = new List(); } } /* Output: net.mindview.simple.Vector net.mindview.simple.List *///:~
At the same level with the access folder there is a package net/mindview/simple, in the simple folder there is a file List.java
//: net/mindview/simple/List.java // Creating a package. package net.mindview.simple; public class List { public List() { System.out.println("net.mindview.simple.List"); } } ///:~
and a file Vector.java
//: net/mindview/simple/Vector.java // Creating a package. package net.mindview.simple; public class Vector { public Vector() { System.out.println("net.mindview.simple.Vector"); } } ///:~
The files Vector.java and List. java compiles normally, but when I try to compile LibTest.java I get the error LibTest.java:3: error: package net.mindview.simple does not exist
I tried compiling with different commands, for example Environment variables are set, path C:\Program Files is added for Path \Java\jdk1.7.0_60\bin, D:\Work\Java\stud is added for CLASSPATH What am I doing wrong, why does the compiler not pull up the package files, as I understand it, it should look for them in CLASSPATH?
javac LibTest.java
javac -classpath . LibTest.java
javac D:/Work/Java/stud/access/LibTest.java
GO TO FULL VERSION