B. Installing the Oracle Java Developer Kit

The Android and BlackBerry development tools use Oracle’s Java Developer Kit (JDK) to build (compile) Java applications for Android. Apple’s Mac OS will either already include the JDK or install it automatically when you run your first Java program, so if you’re installing on a Macintosh computer, you can skip this appendix and move on.

Downloading the JDK

To obtain the JDK, point your browser of choice to http://java.oracle.com, and then click the Get Java button on the landing page. On the page that appears, scroll down and click the Download button for the appropriate JDK version to download.

At this time, Oracle is shipping version 7 of the JDK, but the Android development tools support only versions 5 and 6. Be sure to check to see that the version of the JDK you download is compatible with the Android tools before downloading and installing the software.


Image Note

The Java download site contains different flavors of Java for you to download. The most common options are the Java Runtime Environment (JRE) and the Java Developer Kit (JDK). The JRE is the client-side runtime environment used to run Java applications you may have downloaded over the Internet or installed on your local workstation.


The JDK contains the tools needed to compile Java code into executable applications and applets. To use the Android developer tools, you must install the JDK, not the JRE. So that you can execute Java applications, the JDK includes the JRE, so you’ll be covered for both.

Figure B-1 shows the download options for the JDK. For each supported operating system, there’s a different download depending on whether you’re running a 32-bit or 64-bit operating system. When selecting the files to download, be sure to match the download to both the processor and the operating system running on your development machine, as described in Table B-1.

Image

Figure B-1 Java download options

Table B-1 Determining the JDK to Download

Image

Installing the JDK

Once the JDK has been downloaded, launch the downloaded file to begin the installation. You can simply accept the default installation options to complete the installation. Some installation options may not be needed for your installation (such as source code and Java DB) and can be omitted (as shown in Figure B-2); all the other components are required and cannot be disabled.

Image

Figure B-2 Java installation wizard

Configuring the Windows Path

Once the installation has completed, the Windows Path environment variable must be updated to point to the JDK’s bin folder. This allows the Java tools to be executed by any program on the computer such as the Android developer tools, without specifically pointing to the folder where the JDK is installed. By default the JDK executables will be installed in the Windows Program Files folder (C:Program FilesJavajdk#in, where the # refers to the version of the JDK installed). To modify the Path variable, open the Windows Control Panel and then select System or right-click My Computer and select Properties.

In the System Properties application, click the Advanced System Settings tab, as shown in Figure B-3, and then click the Environment Variables button on the bottom of the window. In the “System variables” area of the Environment Variables window, select Path then click the edit button. In the window that appears (also shown in Figure B-3), modify the variable value field by appending a semicolon at the end of the existing value and adding the full path to the JDK bin folder (C:Program FilesJavajdk1.6.0_27, as shown in the figure) to the end of the value that is already there. Do not replace the contents of the variable value field; simply append a semicolon and the JDK path to the end of the value that’s already there. Click OK repeatedly to close the windows that have been opened during this process.

Image

Figure B-3 Setting the Windows Path environment variable

Confirming Installation Success

To confirm that the Path variable has been set correctly, open a Command Prompt window (shown in Figure B-4), type javac at the prompt, and press Enter. If the path has been correctly configured, the Command Prompt window will fill with instructions on how to use the Java compiler (javac, one of the programs included with the JDK), as shown in the figure. If you receive an error message such as “bad command or file name” or “‘javac’ is not recognized as an internal or external command, operable program or batch file,” then the path has not been configured correctly, and you will need to fix the configuration before continuing.

Image

Figure B-4 Testing the JDK configuration on Windows

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset