没有指定classpath时默认的类路径是什么? [英] What's the default classpath when not specifying classpath?

查看:170
本文介绍了没有指定classpath时默认的类路径是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

想知道什么是未指定classpath选项时的默认类路径?

Wondering what will be the default classpath when not specifying classpath option?

推荐答案

当前工作目录()。

来自 Java™教程:PATH和CLASSPATH


类路径的默认值为。,表示只搜索当前目录。指定CLASSPATH变量或-cp命令行开关会覆盖此值。

The default value of the class path is ".", meaning that only the current directory is searched. Specifying either the CLASSPATH variable or the -cp command line switch overrides this value.



这是否包含子目录?



不,类路径中没有条目是递归的。您必须明确列出每个子目录(或jar)。但是,如果您有一个 Example.class 文件,表示类 pkg.subpkg.Example ,并使用默认的类路径,那么这个文件应该存在于 ./ pkg / subpkg / Example.class

Does this include subdirectories?

No, no entry in the classpath is "recursive". You have to list each subdirectory (or jar) explicitly. However, if you have an Example.class file representing class pkg.subpkg.Example, and the default classpath is used, then this file should live in ./pkg/subpkg/Example.class.

如果 java 尝试解析 pkg.subpkg.Example 它将查找 / pkg / subpkg 每个类路径条目。即您不必列出 pkg pkg / subpkg 在类路径中,只有

If java attempts to resolve pkg.subpkg.Example it will look in /pkg/subpkg of each classpath entry. I.e. you do not have to list ., pkg, and pkg/subpkg in the classpath, only ..

这篇关于没有指定classpath时默认的类路径是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆