Installing the Java Development Kit

Installing the Java Development Kit

1 Installing the Java Development Kit If you run Windows, Linux or Solaris, then you can get the kit at the oracle.com website. Macintosh users have a few other possibilities. Java for Windows, Linux and Solaris As I write this chapter, the exact URL for downloading the Java Development Kit for Windows, Linux or Solaris is www.oracle.com/technetwork/java/javase/downloads. I don't expect that URL to work forever and ever, but if you visit oracle.com and poke around for Java, you'll certainly reach the Java Development Kit download page. One way or another, you should keep a few things in mind: * Java comes in three separate editions. A programming language is a bunch of rules describing the way you can write instructions for the computer to follow. An application programming interface (API) is a bunch of reusable code for performing common tasks in a particular language. (Another name for an API is a library.) There's only one Java language, but the Java language has three official APIs. When you download Java from oracle.com, you download some Java language tools and one of the three Java APIs. Taken together, the big bundle containing the language tools and one of the three APIs is called an edition. The three available editions are as follows: * Java Platform, Standard Edition (Java SE) The Standard Edition has code for anything you can imagine doing on a single desktop computer, and much more. This edition does text-handling, mathematical calculations, input/output, collections of objects, and much more. To create this book's examples, you want the Java Platform, Standard Edition. * Java Platform, Enterprise Edition (Java EE) The Enterprise Edition has code for things you do on an industrial- strength server. The edition includes web server tools, sophisticated database tools, messaging between servers and clients, management of systems, and the entire kitchen sink. * Java Platform, Micro Edition (Java ME) The Micro Edition has code for small devices, such as phones, TV set-top boxes, and Blu-ray players. This edition has limited capabilities that fit nicely into special-purpose devices that aren't as powerful as today's computers. © 2011 John Wiley & Sons, Inc. 2 <Remember> To develop this book's Java programs, you want the Java Platform, Standard Edition. If you already have Java's Enterprise Edition, and you don't want more stuff on your hard drive, the Enterprise Edition is okay. But the Enterprise Edition has much more than you need. * Java comes in several different versions, with several updates to each version. Java's version numbering demonstrates what can happen when the marketing department disrupts the timeline in the space-time continuum. Java's earliest releases were numbered "1.0." Next came version "1.1", then the strangely named "Java 2, version 1.2." The extraneous digit 2 hung around through "Java 2, version 1.3", "Java 2, version 1.4" and finally "Java 2, version 5.0." (The spontaneous jump from 1.4 to 5.0 was lots of fun.) Next up was "Java 6" (with no extra 2 and no ".0"). After that is Java 7. Each version is updated often, so a visit to oracle.com may offer Java SE 7 Update 13 for download. Any version of Java, starting with 5.0 and onward, is fine. Versions such as 1.4 are not sufficient. * Java has two kinds of downloads. When you visit oracle.com, you see two acronyms floating around. You see JRE (Java Runtime Environment) and JDK (Java Development Kit). The JRE has everything you need in order to run existing Java programs. Whether you know it or not, your desktop computer probably has a version of the JRE. The JDK has everything you need in order to run existing Java programs and everything you need in order to create new Java programs. The JDK has the entire JRE and more. The download that you want is the JDK, which includes the JRE. You do not want the JRE alone. <Remember> Download and install the Java JDK, not the Java JRE. * Java might come with other tools. A glance at the Java download page shows several options -- options to download Java with NetBeans, JavaFX, the Java source code, the Java SE documentation, and some other stuff. You might find the Java SE documentation helpful, especially if you don't want to repeatedly visit Oracle's online Java documentation. But the rest of the options (JavaFX and others) don't help with plain, old Java development. After you've downloaded the Java SE JDK, follow the instructions at oracle.com for installing the software. On Windows, you normally double- © 2011 John Wiley & Sons, Inc. 3 click a file with the .exe extension. On Linux, you install an .rpm file or run a self-extracting .bin file. (I've never met a Linux geek who didn't know what to do with these files.) Those pesky filename extensions On a Windows computer, the filenames displayed in My Computer or in Windows Explorer can be misleading. You may visit your Downloads directory and see the name jdk-7u13- windows-x64. Instead of just jdk-7u13-windows-x64, the file’s full name is jdk-7u13-windows- x64.exe. In other directories you may see two MyProgram files. What you don’t see is that one file’s real name is MyProgram.java, and the other file’s real name is MyProgram.class. The ugly truth is that My Computer and Windows Explorer can hide a file’s extensions. This awful feature tends to confuse people. So, if you don’t want to be confused, modify the Windows Hide Extensions feature. To do this, you have to open the Folder Options dialog box. Here’s how: * In Windows XP with the control panel’s default (category) view: Choose Start-->Control Panel-->Appearance and Themes-->Folder Options. * In Windows Vista or Windows 7 with the control panel’s default (category) view: Choose Start-->Control Panel-->Appearance and Personalization-->Folder Options. * In Windows XP, Windows Vista or Windows 7 with the control panel’s classic view: Choose Start-->Control Panel-->Folder Options. In the Folder Options dialog box, click the View tab. Then look for the Hide File Extensions For Known File Types option. Make sure that this check box is not selected. Java for Macintosh The first step is finding out if your system already has the Java Development Kit. You have two choices: * You can trust me on the subject of OS X version numbers. Macintosh OS X 10.5 (codenamed "Leopard") and OS X 10.6 (codenamed "Snow Leopard") have the Java Development Kit pre- installed. If you have either version of OS X (possibly with more dots in the version numbers, such as 10.6.4) then from the Java point of view, you're good to go. Macintosh OS X 10.7 (codenamed "Lion") comes without the Java Development Kit. In fact, no version of the Java Development Kit is formally blessed by Apple for OS X 10.7. So if you purchased OS X 10.7 thinking that you'd have the latest and the best, then you may have gotten the latest, but (depending on your needs) you may not have gotten the best. But don't despair. Instead, keep reading. If you don't trust me about OS X version numbers (and frankly, you shouldn't trust everything you find in print), you have another alternative: © 2011 John Wiley & Sons, Inc. 4 * You can perform tests on your development computer to discover the presence of a Java Development Kit, and of a development kit's version number. You have several choices for these tests. I list two choices in this chapter. Run Java Preferences to determine your JDK version Here's how you run the utility: 1. In the dock, select the Finder. A Finder window opens. 2. In the Finder window's sidebar, select Applications. A list of applications appears in the Finder window's main panel. 3. In the Finder window's main panel, double-click Utilities. A list of utilities appears in the Finder window's main panel. 4. In the list of utilities, look for a Java Preferences entry. If you don't find a Java Preferences entry, then don't fret (... not yet, anyway). You might still have a Java Development Kit. Skip to the test described in the next section. 5. If you have a Java Preferences entry, then double-click that entry. After an uncomfortable delay, your computer displays a window showing information about your computer's Java Development Kit. My Mac displays the name Java SE 6 (along with the more cryptic version number 1.6.0_22-b04-307). That's just fine. <Remember> To develop this book's sample progrems you need Java SE 5 (also known as version number 1.5.0) or higher. If the Java Preferences utility doesn't satisfy your needs, you can poke around in Macintosh's UNIX command window. The next session tells you how. Issue a Terminal command to determine your JDK version 1. In the Spotlight search field, type the word Terminal. 2. When Terminal shows up as the Spotlight's top hit, press Enter. A Terminal window opens (usually with plain black text on a plain white background). 3. In the Terminal window type the following text, and then press Enter: javac -version © 2011 John Wiley & Sons, Inc. 5 On my computer, the Terminal window responds with the following text: javac 1.6.0_22 If your computer responds with the number 1.5.0 or higher, then you can pop open the champagne and look forward to some good times developing Java programs.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    9 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us