I am in c:\new\control
folder and want to execute c:\hello.java
I am trying c:\new\control> javac c:\hello.java
Its creating class file but c:\new\control> java hello
is giving me Error:could not find o load main class hello
In simple way i wan ask , i have class file in c:\ (say c:\hello.class)
I am in c:\user, how can i execute it???
By default, the .class file will be generated alongside the .java file. Options:
Use -d .
when compiling to generate the classes relative to the current directory (including creating subdirectories for packages):
> javac -d . c:\hello.java
> java hello
Specify a classpath when running:
> java c:\hello.java
> java -cp c:\ hello
See more on this question at Stackoverflow