I am trying to run a Java application, but getting this error:
java.lang.ClassNotFoundException:
After the colon comes the location of the cla
This is the best solution I found so far.
Suppose we have a package called org.mypackage containing the classes:
and the files defining this package are stored physically under the directory D:\myprogram (on Windows) or /home/user/myprogram (on Linux).
The file structure will look like this:
When we invoke Java, we specify the name of the application to run: org.mypackage.HelloWorld. However we must also tell Java where to look for the files and directories defining our package. So to launch the program, we have to use the following command:
NOTE: You have to execute the above
javacommand no matter what your current location is. But this is not the case forjavac. For compiling you can even directly go into the directory where you have your.javafiles and directly executejavac ClassName.java.