Hello,
in order to become familiar with "javac [options] [source files]", I've prepared the following
Java files in the following directories:
dev/source/dir1/dir2/dir3/Test.javadev/source/dir1/dir2/dir3/sub/Library.java
Please notice that "dev" is not the root.
My Java files are quite simple - the main issue consists in performing an import in class
Test, as you can see below:
First of all, I'm not sure which import I should use in class Test:
the fully qualified name of the Libray class is "dir1.dir2.dir3.sub.Library" due to the package declaration "package dir1.dir2.dir3.sub", so the class name is atomic.
When I try to compile the Test class with the destination directory (-d) "source/dir1/dir2/dir3 and with different classpath settings, I always get the same error:
source\dir1\dir2\dir3\Test.java:3: package dir1.dir2.dir3.sub does not exist
import dir1.dir2.dir3.sub.Library;
^
source\dir1\dir2\dir3\Test.java:12: cannot find symbol
symbol : class Library
location: class dir1.dir2.dir3.Test
Library lib = new Library();
^
source\dir1\dir2\dir3\Test.java:12: cannot find symbol
symbol : class Library
location: class dir1.dir2.dir3.Test
Library lib = new Library();
^
3 errors
Same thing, when I use the "import sub.Library" commented out in line 3.
My javac command (executing from the
dev directory) is the following:
$ javac
-classpath classes/dir1/dir2/dir3/sub -d classes source/dir1/dir2/dir3/Test.java
I try to tell the compiler that the required class file (Library class, for the import) can be found under
classes/dir1/dir2/dir3/sub.
In fact, the physical file is really located there, I've checked it before!
Besides, I've tried out several combinations concerning paths and imports, but nothing seems to work out.
Any idea?