开发者

About import statement in Java

开发者 https://www.devze.com 2023-01-02 23:33 出处:网络
test.java: import javax.media; Which directories are javax.media searched from? I suppose th开发者_StackOverflow社区ose in CLASSPATH specified by javac -cp will of course be searched.

test.java:

import javax.media;

Which directories are javax.media searched from?

I suppose th开发者_StackOverflow社区ose 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?


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消