关于ClassPath中的current directory

Given:
1. package com.company.application;
2.
3. public class MainClass{
4. public static void main(String[] args){}
5. }
And MainClass exists in the /apps/com/company/application directory. Assume the CLASSPATH
environment variable is set to "." (current directory).

Which two java commands entered at the command line will run MainClass? (Choose two.)
A. java MainClass if run from the /apps directory
B. java com.company.application.MainClass if run from the /apps directory
C. java -classpath /apps com.company.application.MainClass if run from any directory
D. java-classpath . MainClass if run from the /apps/com/company/application directory
E. java -classpath /apps/com/company/application:. MainClass if run from the /apps directory
F. java com.company.application.MainClass if run from the /apps/com/company/application directory
答案:BC

 

any comments?

 

c不对吧,classpath给的是个相对路径/apps,说是run from any directory,虚拟机能找到这个相对路径吗?
给个绝对路径就对了

关于current directory : 我想就是当前执行“客体”所在目录,如果是带有包的类,必须是全包路径,比如com.company.application.MainClass,此 “全限定类”所在目录不是application,而是apps,如果要执行该“类”,classpath也就须设置在apps

你可能感兴趣的:(java,C++,c,C#,F#)