There are several ways to get javac to create a class file /home/bob/class/a.class.
There are two components that interact to determine where javac output will be generated:
The value of the "target directory" specified by the -d option.
The package that the class defined in a.java belongs to. This is specified by the package operator in the java source file.
, , ,
destination directory (-d) | package declaration | comments
/home/bob/classes | not set | you probably have this
/home/bob | classes | not recommended. See note 1.
/home | bob.classes | not recommended.
/ | home.bob.classes | not recommended.
1: , . ,
:
package declaration | package root | recommended path of source file
z | /home/b/project1 | /home/b/project1/z/MyClass.java
y.z | /home/b/project1 | /home/b/project1/y/z/MyClass.java
, , , , , , Java.
CLASSPATH: /jar , , , , . javac dot-java dot-class. java java-/. , -classpath javac/java.
JAVAPATH: /jar , , , java, . javac. , -sourcepath javac.
JAVA_HOME: "root" - Java. /home/bob/java/jdk 1.5.0_06 JAVA_HOME. , Java. , javac java, JAVA_HOME, . JAVA_HOME script .
, . Java 10 . . ? , , , , .