Tuesday, October 23, 2007

Java classpath issues (Problem 1)

Ah well, in this blog I would like to address an issue that I had confronted me about 2 years ago. I really had to pull out all my hairs to resolve this problem a that time since I received no external help. But as good as your luck turns out to  be, I am just glad to be able to help. Setting classpath variables is a headache for novice java programmers. So ill try to make it as simple as possible.

To execute a java program from any directory in your system, u need to do the following(this
is for Windows XP users):
1) Right click on My Computer->properties
2) Go to the Advanced tab
3) You shall see a small button named Environment variables. Thats the
one u need to click.
4) A dialog box will open up showing the various system variables.
5) U need to add a new environment variable in the user variable dialog box. Click on new.

Add the following:
variable name : PATH
Variable value : the complete path to the bin folder of your java
installation directory

For example, on my system, the setting is the follows:

variable name : PATH
Variable value : C:\Program Files\Java\jdk1.5.0_12\bin

There you go. Just go and have a good time playing around with all the java files that u can, and experience the ease with which you can compile the files without setting the classpath each time or painfully copying the files to the bin folder.

No comments: