Setting up your Java development environment
- In this section you will get instruction for downloading and installing JDK and using eclipse IDE
- The JDK include a set of command line tools for compiling and running your code.
- Eclipse is a popular open source IDE for Java development.It handles basic tasks, such as code compilation and setting up a debugging environment, so that you can focus on writing and testing code.You need an installed JDK in order to use Eclipse for Java development.
Install JDK 6
Follow these steps to download and install JDK 6:
- Browse to Java SE Downloads and click the Java Platform (JDK) box to display the download page for the latest version of the JDK (JDK 6, update 21 at the time of this writing).
- Click the Download button.
- Select the operating system platform you need.
- You will be asked for your account username and password. Enter them if you have an account, sign up if you don't, or you can click Continue to skip this step and proceed to the download.
- Save the file to your hard drive when prompted.
- When the download is complete, run the install program. (The file you've just downloaded is a self-extracting ZIP file that is also the install program.) Install the JDK to your hard drive in an easy-to-remember location (such as C:\home\jdk1.6.0_20 on Windows or ~/jdk1.6.0_20 on Linux). It's a good idea to encode the update number in the name of the install directory you choose.
You now have a Java environment on your machine. Next, you will install the Eclipse IDE.
Install Eclipse
To download and install Eclipse, follow these steps:
- Browse to Eclipse Galileo Sr2 Packages.
- Click on Eclipse IDE for Java Developers.
- Under Download Links on the right-hand side, select your platform.
- Select 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 ~/eclipse on 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 have to tell it where the JDK is located.
To set up your Eclipse development environment:
- Launch Eclipse by double-clicking on eclipse.exe (or the equivalent executable for your platform).
- The Workspace Launcher will appear, allowing you to select a root folder for your Eclipse projects. Choose a folder you will easily remember, such as C:\home\workspace on Windows or ~/workspace on Linux.
- Dismiss the Welcome to Eclipse screen.
- Click Window > Preferences > Java > Installed JREs. Figure 1 shows the setup screen for the JRE:
Figure 1. Configuring the JDK used by Eclipse
- Eclipse will point to an installed JRE. You need to make sure you use the one you downloaded with JDK 6. If Eclipse does not automatically detect the JDK you installed, click Add... and in the next dialog Standard VM, then click Next.
- Specify the JDK's home directory (such as C:\home\jdk1.6.0_20 on Windows), then click Finish.
- Confirm that the JDK 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 will familiarize you with Eclipse.
The Eclipse development environment
The Eclipse development environment has four main components:
- Workspace
- Projects
- Perspectives
- Views
The primary unit of organization in Eclipse is the workspace. A workspace contains all of your projects. A perspective is a way of looking at each project (hence the name), and within a perspective are one or more views.
The Java perspective
Figure 2 shows the Java perspective, which is the default perspective for Eclipse. You should see this perspective when you start up Eclipse.
Figure 2. Eclipse Java perspective
The Java perspective contains the tools you need to begin writing Java applications. Each tab shown in Figure 2 is a view for the Java perspective. Package Explorer and Outline are two particularly useful views.
The Eclipse environment is highly configurable. Each view is dockable, so you can move it around in the Java perspective and place it where you want it. For now, though, stick with the default perspective and view setup.
Create a project
Follow these steps to create a new Java project:
- Click on File > New > Java Project ... and you will see a dialog box open like the one shown in Figure 3:
Figure 3. New Java Project wizard
- Enter
Intro
as the project name and click Finish. - If you want to modify the default project settings, click Next. (This is recommended only if you have experience with the Eclipse IDE.)
- Click Finish to accept the project setup and create the project.
No comments:
Post a Comment