Classpath. When yo urun the program in Command Prompt - you need to tell Java which of the compiled programs to use (you might have several different versions and compilations of the same program in different directories). I would recommend typing something like
set classpath=e:/progs
(if your compiled files with extension .class are in that directory on e-drive) or some other drive name. But since you can move your programs to different directories - every time yo start working with Java (or change your class directories) type the Classpath command as shown above. This command doesn't show the location of the system files (like javac.exe, etc.) but the location of your compiled programs (with .java extension). For various tasks you might want to create different subdirecitories (like e:/progs/w1 or e:/progs/w2) where you will place your source code and where after running javac you will find the compiled program with .class extension. Then when you want to run your program by issuing "java myprog" command - the system has to know where is the file that you want to run. Then before running your compiled program you have to set the classpath (one line command as I've just mentioned) but only in case the directory has been changed since you set your classpath in the beginning of the session. If your compiled programs will be in the same directory - then after the initial classpath setting you do not need to repeat it.
For other problems in the future - you can "google" them typing a short representative phrase/keyword in Google search. There are plenty of discussions and people with same problems and other people helping them out, as well as official information on the issue.
The main place for help will remain in QandA of each week...
No comments:
Post a Comment