If you want to compile a class called foo.bar.Baz , you must put the Baz.java file in the foo/bar directory and run javac from the foo parent directory, that is, if you list the contents of the current one, you can see foo . In addition, there is a command line -sourcepath :
javac -sourcepath .:/home/asdf/qwerty foo.bar.Baz.java
Assuming your class is declared as follows
import foo.bar.*; public class Baz {}
you must put this code in the /home/raf/foo/bar/Baz.java file and change to the /home/raf before calling the compiler.
javac will throw a “package foo.bar does not exist” error if it cannot find the foo/bar directory tree in its path to the source file. Thus, you either go to the right directory or use the -sourcepath switch to point to the root of the project, i.e. the directory containing javax/comm . Put your sources in the directory as follows:
+ /home/raf/project/src | +-/javax | +-/comm
and call javac from src directory
cd /home/raf/project/src javac $filenames
or with the switch above
javac -sourcepath /home/raf/project/src $filenames
You need to configure CLASSPATH so that javac compiles with existing archives.
Raffaele
source share