Setting up your Java development environment


In this section, you'll download and install the JDK and the current release of the Eclipse IDE, and you'll set up your Eclipse development environment.
If you already have the JDK and Eclipse IDE installed, you might want to skip to the "Getting started with Eclipse" section or to the one after that, "Object-oriented programming concepts."

Your development environment

The JDK includes a set of command-line tools for compiling and running your Java code, including a complete copy of the JRE. Although you can use these tools to develop your applications, most developers appreciate the additional functionality, task management, and visual interface of an IDE.
Eclipse is a popular open source IDE for Java development. Eclipse handles basic tasks, such as code compilation and debugging, so that you can focus on writing and testing code. In addition, you can use Eclipse to organize source code files into projects, compile and test those projects, and store project files in any number of source repositories. You need an installed JDK to use Eclipse for Java development. If you download one of the Eclipse bundles, it will come with the JDK already.

Install the JDK

Follow these steps to download and install the JDK:
  1. Browse to Java SE Downloads and click the Java Platform (JDK) box to display the download page for the latest version of the JDK.
  2. Agree to the license terms.
  3. Under Java SE Development Kit, choose the download that matches your operating system and chip architecture.

Windows

  1. Save the file to your hard drive when prompted.
  2. When the download is complete, run the install program. Install the JDK to your hard drive in an easy-to-remember location such as C:\home\Java\jdk1.8.0_60. It's a good idea to encode the update number in the name of the install directory that you choose.

OS X

  1. When the download is complete, double-click it to mount it.
  2. Run the install program. You do not get to choose where the JDK is installed. You can run /usr/libexec/java_home -1.8 to see the location of JDK 8 on your Mac. The path isdisplay similar to /Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home.
See JDK 8 and JRE 8 Installation for more information.
You now have a Java environment on your computer. Next, you'll install the Eclipse IDE.

Install Eclipse

To download and install Eclipse, follow these steps:
  1. Browse to the Eclipse IDE downloads page.
  2. Click Eclipse IDE for Java Developers.
  3. Under Download Links on the right side, choose your platform (the site might already have sniffed out your OS type).
  4. Click the mirror you want to download from; then, save the file to your hard drive.
  5. Extract the contents of the .zip file to a location on your hard drive that you'll be able to remember easily (such as C:\home\eclipse on Windows or ~/home/eclipse on Mac or Linux).

Set up Eclipse

The Eclipse IDE sits atop the JDK as a useful abstraction, but it still needs to access the JDK and its various tools. Before you can use Eclipse to write Java code, you must tell it where the JDK is located.
To set up your Eclipse development environment:
  1. Launch Eclipse by double-clicking eclipse.exe (or the equivalent executable for your platform).
  2. The Workspace Launcher opens, allowing you to choose a root folder for your Eclipse projects. Use a folder you can easily remember, such as C:\home\workspace on Windows or ~/home/workspace on Mac or Linux.
  3. Close the Welcome to Eclipse window.
  4. Click Window > Preferences > Java > Installed JREs. Figure 1 shows this selection highlighted in the Eclipse setup window for the JRE.
    Figure 1. Configuring the JDK that Eclipse uses
    Screenshot of correct JDK JRE setup in Eclipse
  5. Eclipse points to an installed JRE. You must use the JRE that you downloaded with the JDK. If Eclipse does not automatically detect the JDK you installed, click Add..., and in the next dialog box, click Standard VM and then click Next.
  6. Specify the JDK's home directory (such as C:\home\jdk1.8.0_60 on Windows), and then click Finish.
  7. Confirm that the JDK that you want to use is selected and click OK.
Eclipse is now set up and ready for you to create projects, and compile and run Java code. The next section familiarizes you with Eclipse.
Share on Google Plus

About M

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.

0 comments:

Post a Comment