Beginning Programming with Java For Dummies
Book image
Explore Book Buy On Amazon
Imagine that you’re expecting a delivery from a local confectioner. In the late afternoon, the mail carrier delivers a box containing your favorite chocolate candy. Naturally, you want to open the box as soon as it arrives.

The same is true about this book’s software. Here’s how you open your newly downloaded IntelliJ IDEA box:

  1. Launch the IntelliJ IDEA application.

    When you do, you see a flashy banner display. After a few seconds, the banner disappears and you see the Welcome to IntelliJ IDEA dialog box. The box is shown in Figure 2-1.

    You can change the IntelliJ color theme by selecting Customize in the Welcome dialog box’s side panel.

    IntelliJ IDEA Welcome Screen FIGURE 2-1: Willkommen, bienvenue, welcome!
  2. In the Welcome dialog box, choose New Project.

    A Java application may consist of several files, including code files, image files, data files, installation instructions, and other stuff. With IntelliJ IDEA, you manage an application’s files by combining them into a single project.

    In this book, a typical project contains only one file. Why bother “collecting” one file into a bigger thing called a “project”? The answer is, IntelliJ IDEA wants each application to be part of a project, just in case the application grows to include dozens or even hundreds of files.

    When you select New Project, a dialog box appears. To no one’s surprise, the box’s title is New Project. (See Figure 2-2.)

    IntelliJ IDEA New Project Screen FIGURE 2-2: Everything starts here.
  3. Make sure that the topmost entry (namely, Java) is selected in the dialog box’s side panel. (Refer to Figure 2-2.)

  4. At the top of the dialog box’s main body, look for the drop-down list labeled Project SDK. (Refer again to Figure 2-2.)

    The letters SDK stand for software development kit. During its long history, Java has come in many different shapes and sizes. Even now, the kind of Java you run depends on the kind of Java you need. This drop-down box asks you to select the kind of Java you’ll be using in your new project.

    For more than you’d like to know about Java’s many incarnations, see the later section “The Java smorgasbord.”

    What you do next depends on what you see in that drop-down list.

  5. If you see in the drop-down list, jump temporarily to the later section “Installing Java.”

    Likewise, if you see Version 16 or any version lower than 16 (including versions like 1.8.0_241) in the drop-down list, jump temporarily to the later section “Installing Java.”

    If you see Version 17 or any version number higher than 17, leave the drop-down list as it is and click Next.

    After clicking Next, you see a second New Project dialog box. You can proceed to the next step in this list of instructions.
  6. The second New Project dialog box displays the Create Project from Template check box. Put a check mark in the Create Project from Template check box. (See Figure 2-3.)

    Create Project from template in IntelliJ IDEA FIGURE 2-3: Care to use a project template?
  7. In the same New Project dialog box, make sure that the Command Line App item is selected. (Refer again to Figure 2-3.)

  8. At the bottom of this New Project dialog box, click Next.

    When you click Next, a third (and, thankfully, final) New Project dialog box asks for a project name, a project location, and a base package (See Figure 2-4.)

    For the project name, almost any sequence of characters will do. In Figure 2-4, I use the name 02-01. After all, this is Chapter 2, and this is the first (and only) project in Chapter 2.

    For the project location, I recommend keeping the default.

    New Project Dialog Box FIGURE 2-4: What, where, and how.
  9. Delete any text in the Base Package field. (Refer to 2-4.)

    My Java colleagues will rip me to pieces for telling you to leave the Base Package field empty. A package is a group of one or more Java code files, and experienced Java professionals never write code without naming a package. The trouble is, having a named base package would make it slightly more difficult for you to run this book’s sample programs. The quickest (and dirtiest) solution is to have you clear out the Base Package field. Don’t tell anyone. It’s our little secret.

  10. In this final New Project dialog box, click Finish.

    At last! IntelliJ’s main window appears on your computer screen.

    Figure 2-5 contains a screen shot of the main window. In the figure, I’ve labeled a few of the main window’s parts.

    IntelliJ's IDEA main window FIGURE 2-5: IntelliJ IDEA’s main window.

    It may take a while for IntelliJ to finish creating a new project. You may see only a big gray area in most of the main window. You may see some messages about indexing on the status bar. If so, be patient. Wait for the text on the status bar to stop changing. Figure 2-6 shows what you see when the status bar in Figure 2-5 stops changing.

    IntelliJ IDEA's status bar FIGURE 2-6: Tranquility on the status bar.

    With no turmoil on the status bar, you may still not see the Editor or the Project tool window.

    • If you don’t see the Project tool window, you can coax it out of hiding: Just click the Project tool button along the window’s leftmost edge.
    • If you don’t see the Editor, expand the Project tool window’s tree and double-click the tree’s Main branch. (Refer to Figure 2-5.)
    Enough preliminaries. It’s time to run some Java code.
  11. Click the Run button.

    When you do, you should see some new messages on the IntelliJ status bar. After a number of seconds, you see a new tool window — the IntelliJ Run tool window — along the bottom of the screen. (See Figure 2-7.) Along with some technical gobbledygook, the Run tool window displays the words Process finished with exit code 0.

    IntelliJ's Run tool window FIGURE 2-7: Not much to see here.

    That’s it! You’re done setting up the software. For answers to questions about any of these steps, see the later section “If You Need More Details . . . .”

Installing Java

What? You say you were following the previous section’s steps and then Step 5 in that section made you take a detour? Well, you’ve come to the right place!

When you reached Step 5, you were staring at the New Project dialog box. Maybe the text appeared in the dialog box’s Project SDK drop-down list. (Refer to Figure 2-2.) Or maybe the drop-down list displayed a version number lower than 17.

In either case, here’s what you do next:

    1. In the Project SDK drop-down list, select Download JDK. (See Figure 2-8.)

      Project SDK drop-down list FIGURE 2-8: IntelliJ offers to download Java for you.

      When you select Download JDK, IntelliJ displays a new Download JDK dialog box. (See Figure 2-9.)

      Download JDK dialog box FIGURE 2-9: Pick your poison.
  1. In the Download JDK dialog box’s Version list, select the highest number available.

  2. For the Vendor drop-down list, I recommend the Oracle OpenJDK option.

    I don’t have a particularly good reason for recommending this option. Oracle owns the rights to Java, so using Oracle’s product means getting Java “from the horse’s mouth.” And the prefix Open in OpenJDK means that this version of Java is free to use for noncommercial purposes.

    No matter which vendor option you pick, you’ll be okay. This book’s examples run on any newer version of Java. The third item in the Download JDK dialog box is a Location field.

  3. In the Location field, your safest move is to accept the default.

    In other words, leave that field alone.
  4. When you’re finished making selections, click the Download button.

    As if by magic, IntelliJ downloads Java and installs it on your computer.
  5. In the New Project dialog box, click Next.

    As a result, another dialog box with the same title (New Project) appears. With this second New Project dialog box staring you in the face, you can return to Step 6 in the previous section.

    It was fun guiding you through this section’s steps. Please say hello to the “Firing up IntelliJ IDEA” section for me!

About This Article

This article is from the book:

About the book author:

Dr. Barry Burd holds an M.S. in Computer Science from Rutgers University and a Ph.D. in Mathematics from the University of Illinois. Barry is also the author of Beginning Programming with Java For Dummies, Java for Android For Dummies, and Flutter For Dummies.

This article can be found in the category: