I figured it out!
Let me write down my findings in case someone else finds it useful.
First of all, PATH has NOTHING to do with Java. PATH is a way for you to reference programs (.exe files) that are located in a directory other than your current directory. For example, let's say you have an old-school program that you run from the command line. If the program is normally stored in C:\Program Files\whatever\whatever.exe, you would need to navigate to the "C:\Program Files\whatever\" directory to execute it. But when you open a command window, you normally start in "C:\" (let's just say).
Setting your PATH variable to "include" the "C:\Program Files\whatever" directory means that if you type "whatever.exe" on the command prompt, it will first look in the current directory, and it will not find whatever.exe, so it will start looking at the alternative paths that are in the PATH variable.
To do so, you would type
PATH = %PATH%;C:\Program Files\whatever
This means that you want the path variable to now be equal to the old path variable (that's the %PATH% part), plus whatever you put after that. Always separate directories with a semi-colon (;).
Why does this matter for Java? Well, you need to execute javac.exe and java.exe to run Java programs, right? Well, they are normally stored in some weird directory (like C:\Program Files\Java\jdk\1.6.0_06\bin). But you put your source code in a separate location, such as C:\source\.
To run javac.exe to compile your .java files, you need to type C:\Program Files\Java\jdk\1.6.0_06\bin\java.exe whatever.java. That's a lot of typing each time you want to run a compile. To make it easier on yourself, you change your PATH variable so that DOS knows where to find javac.exe and java.exe.
Make sense?
Now let's talk about the classpath. The classpath is a Java thing.
Classpath is a way to tell the java virtual machine (ie java.exe) where to find the .class files.
If you start to use packages (and
you should!) it's important to understand this.
Suppose you have a file with a package declaration statement. You should store this file in a directory that matches the package hierarchy.
This file should be stored at:
CLASSPATH ROOT\com\joseph\hello\
Now you need to make sure that the directory that holds the "com" folder is in your classpath.
Executing this:
set classpath
Will result in the system displaying the current classpath.
Executing this:
set classpath = C:\
Will make java know where to look for your packages.
To execute the program, after compiling, you write:
java com.joseph.hello.HelloWorld
java.exe will look for a com folder in the classpaths root (C:\) and then it will look for a folder called joseph in the com folder, etc., until it finds the HelloWorld class.
Clear as mud?