Friday, September 20, 2013

Building a Simple Java Program Part 1: Setting Up an IDE and the Operating Enviroment

          Java programming is a difficult programming language to learn.  It is also one of the most rewarding.  In this blog, we are going to discus how to set up an development environment in a operating system to allow us to program in Java.  We are going to look at the Eclipse Integrated Development Environment (IDE) and how to prep the Java Development Kit.  As we go through the blogs, we will also look at some reasons Eclipse does thing.  Lets get started with installing the JDK and Eclipse.

          First, lets install the JDK.  It can be found on the Oracle website.  http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html.  Make sure you choose the download that matches your operating system.  Also, you don't need the demo and samples download.  After it downloads, run the program and follow the instructions.  Onces installed, make sure that Java can run by opening a command prompt and typing "java -version".


          If this looks somewhat like the results you got, then you are good to go for installing eclipse.  If not, you need to update the window PATH variable.  This can be done by going into Control Panel->System->Advance System Settings->Environment  Variables (On Vista/7).  Find the PATH variable.  I recommend you look in the system variables.  You will need to add in the path to Java.  If you installed JDK 64, it will be located in the Program File folder.  If you installed JDK 32 on a 64 Bit OS, it will be located in program files (x86).  Copy the entire path.  Mine would look like: C:\Program Files\java\jdk7.0.03\bin. At the end of the PATH variable, start by adding a semicolon and add the path.  (NOTICE:  COPY THE PATH variable into notepad before you add anything to it.  ALT+A will select all and ALT+C to copy, ALT+P to paste.  You may need it if you make a mistake.)  You will have to reboot your computer after this is done.  After the restart, try running the above command again.  If all works, go on and start the instructions to install eclipse.

          When you go to the Eclipse website, you will notice that there are a several types of packages you can download. http://www.eclipse.org/downloads/.  The one I recommend is getting the one that is just for Java Developers.  You are welcome to get the Java EE version which will include a lot of Java libraries built for an Enterprise.  Make sure you choose what type of OS you have.  After the download, extract the files into a folder where you can locate it.  Eclipse doesn't need to be installed, it will run straight from the folder.   Eclipse.exe is the file that will start the program.

          You should get the welcome page.  Notice: I use Java EE; yours might say something else.  This welcome page is nice to get a feel for eclipse as it provides examples, but we are going to skip this part.  In the top left corner, you should see workbench.  Click that.  It'll take you to the location where we are going to work.  Eclispe from this point should be setup to start programing in Java, but if you are having issues, you can see http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.jdt.doc.user%2FgettingStarted%2Fqs-2.htm for further help.  You might want to review it to make sure the settings are correct before you begin.  Next blog we will look at how to create our first program and packages.

No comments:

Post a Comment