• Tidak ada hasil yang ditemukan

COMPRESSED ARCHIVE FILES

Dalam dokumen Beginning Programming with Java (Halaman 42-46)

When you visit www.allmycode.com/BeginProg and you download this book’s Java examples, you download a file named BeginProgJavaDummies5.zip . A .zip file is a single file that encodes a bunch of smaller files and folders. For example, my BeginProgJavaDummies5.zip file encodes folders named 06-01 , 06-02 , and so on. The 06-02 folder contains some subfolders, which in turn contain files. (The folder named 06-02 contains the code in Listing 6-2 — the second listing in Chapter 6 .)

A .zip file is an example of a compressed archive file. Some other examples of compressed archives include .tar.gz files, .rar files, and .cab files. Uncompressing a file means extracting the original files stored inside the big archive file. (For a .zip file, another word for

uncompressing is unzipping. ) Uncompressing normally re-creates the folder structure encoded in the archive file. So, after uncompressing my BeginProgJavaDummies5.zip file, your hard drive has folders named 06-01 , 06-02 , with subfolders named src and bin , which in turn contain files named SnitSoft.java , SnitSoft.class , and so on.

When you download BeginProgJavaDummies5.zip , your web browser may uncompress the file automatically for you. If not, you can see the .zip file’s contents by double-clicking the file’s icon. (In fact, you can copy the file’s contents and perform other file operations after double- clicking the file’s icon.) One way or another, don’t worry about uncompressing my

BeginProgJavaDummies5.zip file. When you follow this chapter’s instructions, you import the contents of my BeginProgJavaDummies5.zip file into the Eclipse IDE. And behind the scenes, Eclipse’s import process uncompresses the .zip file.

Setting Up Java

You can get the latest, greatest versions of Java by visiting

www.oracle.com/technetwork/java/javase/downloads . Look for the newest available version of the JDK. Select a version that runs on your computer’s operating system.

Figure 2-1 shows me clicking a Download JDK button (circa March 2014) at the Oracle website. When you visit the site, the page on your computer screen probably looks a lot like Figure 2-1 , but you might see Java SE 9 instead of Java SE 8.

If you see Java 9, go for it.

If you see Java 8 instead of Java 9, scroll down to find an early access Java 9 preview.

With plain, old Java 8, you can run all the programs in this book. But if you have Java 9, you can use JShell — a tool for experimenting

quickly and easily with snippets of Java’s code.

FIGURE 2-1: Getting the Java JDK.

The Oracle and Eclipse websites that I describe in this chapter are always changing. The software that you download from these sites changes, too. A specific instruction such as “click the button in the upper-right corner” becomes obsolete (and even misleading) in no time at all. So in this chapter, I provide long lists of steps, but I also describe the ideas behind the steps. Browse each of the

suggested sites and look for ways to get the software that I describe.

When a website offers you several options, check the instructions in this chapter for hints on choosing the best option. If your

computer’s Eclipse window doesn’t look quite like the window in this chapter’s figures, scan your computer’s window for whatever options I describe. If, after all that, you can’t find what you’re looking for, check this book’s website (

www.allmycode.com/BeginProg ) or send an email to me at

BeginProg@allmycode.com .

If you can’t identify the most appropriate Java version or if you want to know what the acronyms JRE and JDK stand for, see the later sidebar entitled “Eenie, meenie, miney mo .”

Downloading and installing Java

After you accept a license agreement and click a link to a Java installation file, your computer does one of two things:

Downloads and installs Java on your system

Downloads the Java installation file and saves the file on your computer’s hard drive

If the installation begins on its own, follow the instructions, answer Yes to any prompts, and (unless you have good reason to do otherwise) accept the defaults. If the installation doesn’t begin on its own, start the installation by double-clicking the downloaded installation file.

If your computer runs Linux, the downloaded file might be a

.tar.gz file. A .tar.gz file is a compressed archive. Extract the archive’s contents to a folder of your choice and follow the

installation instructions posted on the Oracle website.

For more information about filenames, file types, and archives, see the earlier sidebars entitled “Those pesky filename extensions ” and

“Compressed archive files ” in this chapter.

While you’re visiting

www.oracle.com/technetwork/java/javase/downloads , you can also download a copy of the Java API documentation. Look for a download labeled Java SE Documentation (or something like that).

Accept the license agreement, click the download link, and watch the file flow downward onto your computer’s hard drive. The downloaded file is a compressed .zip archive, so you can uncompress it the way you uncompress all other such archives.

(The uncompressed folder is a bunch of web pages. To start reading the Java API documentation, look in that folder for an index file or an index.html file. Double-click the file, and you’re on your way.)

For an introduction to the Java API documentation, refer to Chapter 1 .

Most people have no difficulties visiting the Oracle website

java.oracle.com and installing Java using the website’s menus. But if your situation is more “interesting” than most, you may have to make some decisions and perform some extra steps. The next few sections describe some of these “interesting” scenarios.

Dalam dokumen Beginning Programming with Java (Halaman 42-46)