10th February 2006

The Path to javac

Quite a few people including myself have been having problems getting the Java Development Kit, namely javac.exe to work properly on our PC's even after installing every possible download from the java.sun.com web site. So here's how.

The reason it's not working for any of us is that you have to manually add it to the path, if you still don't know what I'm talking about (it's not unusual) follow the steps below.

Windows

If you've already installed the JDK, jump to step 3.

  1. Get J2SE 5.0 from Sun's site. It's in the separate bundles bit of the "J2EE 1.4 SDK and Sun Java System Application Server Platform Edition 8.2 January 27, 2006" section. I would link you directly but the punks use sessions.

  2. Install it by completely ignoring all dialogs and speed-tapping the "Next" button taking half a second to click "I agree" on the license agreement.

  3. Open up a Windows Explorer window and browse to C:\Program Files\Java, you should have another sub folder called jdk1.5.0_06 (or whatever version you installed), double-click into it and into the "bin" folder. This is where the evasive javac.exe file hides.

  4. Click to enlarge

    Copy the folder path out of the address bar by selecting it all, right-click and choose "Copy". See image over there >

  5. Now right-click on My Computer (from the desktop or in the Start menu) and select "Properties". On the "Advanced" tab, choose "Environment Variables". It's entirely up to you whether you use the "User variables..." or the "System variables" either way scroll down to find the "PATH" variable and click "Edit".

    Edit: On Andy's machine this didn't work unless it was put in the user variables.

  6. In the "Variable value" box, add a semi-colon on the end (make sure you do not delete what is already there) and press Ctrl+V to paste in the location of javac.exe.

  7. Keep clicking OK until everything is out of your face.

  8. Important: The command will not start working until the next time you open a DOS prompt window. If you have a DOS prompt open, close it, when you next load a DOS prompt, the "javac" command should now work. If it doesn't work, check the path is right from step 5, if it is then continually beat your PC until you feel better.

Linux

I have no idea if anyone else is a penguin head, but this is how to do it on Fedora Core, the same should apply for Red Hat or any other distro' that uses the bash console. If you're distro' doesn't use bash, a quick Google search should tell you which file you need to modify.

With root access

  1. Get J2SE 5.0 from Sun's site. It's in the separate bundles bit of the "J2EE 1.4 SDK and Sun Java System Application Server Platform Edition 8.2 January 27, 2006" section.

  2. Install it obviously, if you used the RPM, it should install to /usr/java/jdk_version.

  3. Create a new file in /etc/profile.d called java.sh (or anything you want).

  4. Without forgetting to check that your using the same version, put in the file:

    PATH=$PATH:/usr/java/jdk1.5.0_06/bin

  5. Save the file, the changes won't take effect until you next login, to make them take effect without having to log out just issue the same command from step 4 at the console.

Without root access

If you don't have root access follow the steps above, but use the file ~/.bash_profile.