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:- Browse to Java SE Downloads and click the Java Platform (JDK) box to display the download page for the latest version of the JDK.
- Agree to the license terms.
- Under Java SE Development Kit, choose the download that matches your operating system and chip architecture.
Windows
- Save the file to your hard drive when prompted.
- 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
- When the download is complete, double-click it to mount it.
- 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.
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:- Browse to the Eclipse IDE downloads page.
- Click Eclipse IDE for Java Developers.
- Under Download Links on the right side, choose your platform (the site might already have sniffed out your OS type).
- Click the mirror you want to download from; then, save the file to your hard drive.
- 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:
- Launch Eclipse by double-clicking eclipse.exe (or the equivalent executable for your platform).
- 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.
- Close the Welcome to Eclipse window.
- 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
- 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.
- Specify the JDK's home directory (such as C:\home\jdk1.8.0_60 on Windows), and then click Finish.
- Confirm that the JDK that you want to use is selected and click OK.
0 comments:
Post a Comment