0

I saved my java file in d:\Vnew.

Compiled it from other folder(C:\>javac d:\Vnew\Vsimple.java) in command prompt which works fine.

But when I try to run (C:\>java d:\Vnew\Vsimple),getting below error:

Error: Could not find or load main class d:\Vnew\Vsimple Caused by: java.lang.ClassNotFoundException: d:\Vnew\Vsimple

Note: If I run from same folder, d:\Vnew, it works fine.

What could be the reason?

hooknc
  • 4,854
  • 5
  • 31
  • 60
Kannan C
  • 93
  • 2
  • 3
  • 9

1 Answers1

1

JVM about d:\Vnew path at compile time only. While running the MainClass, he doesn’t know that there is a class Vsimple in different directory Try to execute with -cp option

C:>java -cp d:\Vnew\; Vsimple

Ravi Saini
  • 26
  • 1