Reputation: 13
My hard drive has 3 partitions as c, d and e. c drive is the main one.
I'm running these following codes through the VScode.Not the CMD or PowerShell also I didn't used the terminal section of the VScode.I just opened the files through the VScode and run them And I got the each following output
So here is what's happening
I'm Running the code saved in c
public class Test {
public static void main(String[] args) {
System.out.println("this is working");
}
}
Output of the file which is saved in c
Running] cd "c:\lec c\" && javac Test.java && java Test
this is working
[Done] exited with code=0 in 3.176 seconds
I'm Running the code saved in d
public class Test {
public static void main(String[] args) {
System.out.println("this is working");
}
}
Output of the file which is saved in 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
I'm Running the code saved in e
public class Test {
public static void main(String[] args) {
System.out.println("this is working");
}
}
Output of the file which is saved in 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
I want to know why this is happening to the files saved in "d" and "e". The little that I know is the reason may involved with the environment variables But its not clear enough to me.
Can some one explain me the exact reason. Thankyou for your time and effort.
Upvotes: 0
Views: 88
Reputation: 141
You must use Extension Pack for Java
to run Java instead of Code Runner
.
Upvotes: 1
Reputation: 8247
You didn't say whether you were running from Powershell or Cmd.
If you are running from the cmd prompt, use cd /d
. If you just use cd
it stays on whatever drive you were on.
Upvotes: 3