There are a few things that every Java developer needs in order to write code. There are plenty of tools out there that can make Java application development easier, but none of them is absolutely necessary and there are almost always alternatives to any tool. However, the Java Development Kit (JDK) is not optional for Java developers. It is absolutely mandatory. This five minute tutorial will guide you step by step through the process of downloading and installing the latest stable version of Java and configuring it to work on your system, including setting key variables such as JAVA_HOME. For your convenience, a written transcription of the video follows.
Hi, I’m Cameron McKenzie. I’m the author of Hibernate Made Easy and a few other Java and JSF development guides. I want to take you through the process of downloading and installing the latest version of the JDK. If you want to do any Java development or JSF development or Hibernate development, the first thing you’re going to have to do is mosey on over to developers.sun.com and download the JDK. When you get here there are going to be all sorts of things for you to download. They want you to take a look at a variety of different NetBeans projects and Java EE platforms; don’t get that complicated. All you want to do is download the Java JDK. And again, there are going to be all kinds of options for downloading.
This is the one I want, download the latest JDK, Java Development Kit. Again, you’ll see Java FX, NetBeans, and Java EE. Those aren’t the things I want. What I want is right here, just a standard Java Development Kit, the JDK. When I click on that I think the current update is JDK6, update 18. That’s going to be fine for JSF 1.2 or 2.0 development or even working with Hibernate. Really we just need a JDK version 5 or better. Now to do this, because I’m using a Windows platform, I’m going to click on the little download link there. I actually don’t want to fill out this registration right here, so I’m going to skip that step. It’s a little bit of a download. I think it’s going to be about 70 MB in size. I definitely want to save that. I’ll give that a couple of minutes to finish downloading.
I’ve actually cheated a little bit, if I say “show in folder” you’ll see a JDK install already downloaded there. I’m going to double click on that JDK install. You can see it’s about 78 MB in size. I’m going to walk through the basic installation here. Now, one of the things I like to do when I’m installing software is to install to an easy to find directory. (I’ll accept the licensing agreement here.) When it asks me where to install, I hate that C:\program files\ thing. I like to throw [important] things into a folder that starts with a leading underscore. That way, I can always find it when I open up Windows Explorer because it’s right at the top. I’m just going to name this JDK 1.6. I’m going to click “okay” accept all the basics there to be installed, click “next” again. A little unzipping happens and the JDK very quickly gets installed.
Now, along with the JDK, there is also an installation of a Java Runtime Environment, the JRE. I’m not really too concerned where the Java Runtime Environment gets installed so I’m just going to accept the defaults there. Click “next” and magically everything gets installed and it’s just a matter of clicking on the “finish” button. If I mosey on over to Windows Explorer and take a look at the C drive, hopefully I will see a C:\_JDK folder. There it is and there is the bin directory with all those tasty and important files in it, mainly things like the Java C compiler and the Java.exe Runtime Environment. Even going on to the command prompt and browsing down to the JDK, moving into the bin directory, I should be able to day Java-version and there we see everything seems to be working and I’ve got 1.6.018 installed.
Finally, after you’ve installed the JDK, one of the things you’ll need to do is [configure] a system setting. I’m going to have to go in and I’m going to have to configure the Java path. I go into control panel > system and I’m then going to set a user variable so I move to the advance tab, click on “environment variables” and I need to set a new system variable. So I click the “new” button right there. I want to set the JAVA_HOME variable to the name of my installation directory, which is C:\_JDK1.6 if you put the underscore in there you have to remember to put the underscore in the system settings. There we go, that value is set. I now have the JAVA_HOME set pointing to my JDK installation directory.
Sometimes people make the mistake of making it JDK1.6\bin. That’s not necessary for the JAVA_HOME, just wherever you did the installation. I click “okay,” click “okay” again, and then I can be fairly happy that I have successfully installed the JDK and configured the JAVA_HOME environment variable. I’m ready to do things like start compiling code and maybe even installing Tomcat and other tools that I can do some advanced Java EE development.