我的硬盘有 3 个分区:c、d、e。 c盘是主要的。
所以这就是发生的事情
我正在运行保存在 c
中的代码public class Test {
public static void main(String[] args) {
System.out.println("this is working");
}
}
保存在 c
中的文件的输出Running] cd "c:\lec c\" && javac Test.java && java Test
this is working
[Done] exited with code=0 in 3.176 seconds
我正在运行保存在d
中的代码public class Test {
public static void main(String[] args) {
System.out.println("this is working");
}
}
保存在d
中的文件的输出[Running] cd "d:\lec d\" && javac Test.java && java Test
error: file not found: Test.java
Usage: javac <options> <source files>
use --help for a list of possible options
[Done] exited with code=2 in 0.593 seconds
我正在运行保存在 e
中的代码public class Test {
public static void main(String[] args) {
System.out.println("this is working");
}
}
保存在 e
中的文件的输出[Running] cd "e:\lec e\" && javac Test.java && java Test
error: file not found: Test.java
Usage: javac <options> <source files>
use --help for a list of possible options
[Done] exited with code=2 in 0.532 seconds
我想知道为什么保存在“d”和“e”中的文件会发生这种情况。我知道的一点是,原因可能与环境变量有关,但对我来说还不够清楚。
有人可以向我解释一下确切的原因吗? 感谢您的时间和精力。
你没有说你是从 Powershell 还是 Cmd 运行。
如果您从 cmd 提示符运行,请使用
cd /d
。如果您只使用 cd
,它会保留在您所在的任何驱动器上。