A funny thing in class today. Well the students were supposed to run some java code with the good old command prompt for the first time, but some had problems running the 'java' and 'javac' commands. Of course they could just do something like:
C:\java_stuffs> javac -cp . MyClass.java
C:\java_stuffs> java -cp . MyClass
But there's no reason why after setting the classpath/path, it still don't work. In some instances, I set either one, it works. So it's just weird. Anyway, below is what I did:
1. Open up 'Control Panel'
2. Double click on 'Systems'
3. Select the 'Advanced' tab
4. Click on 'Environment Variables'
5. Look for 'PATH' under 'System Variables' as can be seen in the image below.
6. Edit the 'PATH' variable but don't delete whatever that may be inside!
7. Move your mouse cursor all the way to the end of the text that you see in 'PATH' and paste your java path at the end. It should look something like this: ';C:\j2sdk1.4.2_07\bin'
There have been occasions where I needed to add a '.' to my PATH, something like this: '.;C:\j2sdk1.4.2_07\bin'
And yet there are times when I have to do the above steps but instead of using the PATH variable, I use the CLASSPATH. (Sometimes I have to create it as it is missing.)