tags:

views:

54

answers:

2

test.java:

import javax.media;

Which directories are javax.media searched from?

I suppose those in CLASSPATH specified by javac -cp will of course be searched.

But will it also search in the directory where test.java locates?

And are there any other possible places that will be searched?

+1  A: 

Consult the specifications for your compiler. For sun's javac, the search order is described in its manual.

Depending on a few things the manual details, class files in the paths set in the CLASSPATH environment variable, class files in the paths set the -classpath command line option, source files in the paths from the '-sourcepathoption, source files in user classpath (if-sourcepathisn't given), and either the JVM's default boot and extension paths or the paths given by the-bootclasspathand-extdirs` options.

As javax.media is a JVM extension, javac would look either in the JVM's extensions directory, or that provided by -extdirs, then in user class folders, then in user source folders.

Pete Kirkham
Is there a command to output the searched directories of `javac`?
A: 

The simplified version is: It's only directories and jars in your classpath, but quite often people put "." in their classpath which would allow searching of directories under the current in the same way as any other classpath directory.

Bill K