Preliminary Tasks

Before downloading, installing, and setting up software, there are a few things you should do to make your environment more suitable for programming.

Switch to a Mono-Spaced Font

You'll find as you program that it's difficult to tell certain characters from one another, so a good mono-spaced font meant for programming will help. Read the notes on Fonts and choose a font to download and install (instructions included).

Using a mono-spaced font for coding will also be helpful when you want to create formatted output, as all the characters will be the same width.

Show File Extensions

For some reason, it's the default in Windows to not show file extensions. This is a huge pain for developers because application source and bytecode files have the same names, but different extensions. Hovering over a file will usually tell you the file type but many editors also use unrecognized extensions for their backups, and these might not have any meaningful information in the hovertext. Therefore, all developers turn on the file extensions so you can quickly differentiate between the different file types:

  1. Use the Windows 10 search: search for "file explorer options"
  2. You should see an entry for "File Explorer Options" and the words "Control Panel" below it in smaller letters. Click File Explorer Options.
  3. In the File Explorer Options dialog box, click the VIEW tab.
  4. Look for the check box labeled "Hide extensions for known file types" (it's about 8 or 10 items down) and make sure it's NOT checked.
  5. Click the OK button.

Change folder options to show file extensions

Create Some Folders/Directories

First, make sure you've created a directory/folder on your hard drive for these tutorials. DO NOT create this directory/folder in your Program Files/Java directory!!! In fact, you should never store any of your own files inside any of the Program Files folders/directories. The Program Files (and Program Files(x86)) directories have special permissions that disallow the creation and editing of other files except by certain applications. Saving your Java programs in this location will cause problems: they may not run and they may not be accessible to your editor or other prorgrams you create.

Nor should you ever store your files directly on the desktop: The items on the desktop are not included in a Windows System Restore, so if you ever have to restore your computer after something bad happens, you'll lose all the files stored on the desktop. Most file backup applictions also ignore the desktop files and won't back these up for you.

A good place to store your Java files is in your Documents directory/folder: create a sub-folder/sub-directory with a name that works for you (e.g. JavaTutorials or wendijava or just "java" - whatever you like).

After creating a folder for these tutorials, you might eventually wish to create sub-folders/sub-directories for each lesson, or each unit. It's up to you, but make sure you keep things organized and easy to find: there might be lessons where you're asked to go back and edit programs you've written before in other lessons.


directory structure for this course
An example of the directory structure for this course and your other courses. You should at least have a directory for this course that contains a "projects" directory.

Bookmark the Java Documentation

The Java API documentation is useful as you're learning about the different classes that make up the Java language. In many lessons we'll be looking at this documentation, so you should have it bookmarked. Your instructor or professor will let you know which version of Java you'll be using.

Using your preferred browser, go to the appropriate link below and bookmark it or add it to your "Favourites". Tip: in some browsers you can add frequently used bookmarks to one of the button bars at the top of your browser, or to the set of favourite links that appears when you open a new browser tab/window.

Downloading Java

The next step is to download and install JavaSE.

Recall in an earlier lesson we talked about what the Java SE contains: The Java development environment, or JDK, which is needed by programmers to write and debug Java programs. It also contains the JRE, or Java Runtime Environment. The JRE contains the JVM (Java Virtual Machine) and other supporting files needed to run Java programs.

For these tutorials, we will download and install the latest version of Java SE, but if you've already done some development with Java and have an older version, that's fine. However, if your current Java version is older than 11, I strongly recommend you get the latest version today. Note that if you have a version earlier than 15, you'll have to perform some extra setup steps if you want to use a basic editor like Notepad++. But otherwise, you won't be doing anything in these tutorials that is significantly different between the Java versions mentioned above.

Java is updated regularly, so keep in mind that the version numbers or "Update" number you see in the examples below may not be the same. As long as you have the latest update, that's all that matters.

  1. Go to the Java SE Download Page. The current version of Java when these notes were last updated is version 17, so that's the version that will be used here. If there is a newer version, go ahead and get that version, instead.
    the Java downloads page
    The Java downloads page for Java SE
  2. Scroll down the page until you find the Java SE Development Kit Downloads table. Select the tab for your operating system, then click the link to download the JDK. If you're new to installing software, select an executable installer (it has the extension .exe) - it's the easiest to deal with.
    the main Java SE downloads page showing the heading Java Platform Standard Edition, and below that is the link to Java SE 14
    Click the link to the current Java Development Kit
  3. Your browser should show the download progress near the bottom of the window, and when it's done, you can click to open the downloaded file. If you don't see this, go to the browser's downloads directory and look for a file with a name similar to "jdk-17_windows-x64_bin.exe".

Depending on the speed of the network and the number of connections, it make take some time for the file to download. Once you are able to open the file, the installation will begin.

Installing Java

The JDK is a collection of tools, utilities, and packages that allow you to write programs in the Java language. It does not come with a development environment, so you will also need an editor or IDE, which we'll do in the next step.

Installing the JDK

  1. After the download has finished, run the installer executable file if it's not already running.
  2. This begins the installation of Java. Most of the default options in each dialog are fine, but you're welcome to change them as long as you know what you're doing. Otherwise, leave the various options as is or as instructed in these notes.
  3. Otherwise, just click NEXT on each screen until you get to the last one.

    first screen of installation: installation begins
    Installation begins: click the NEXT button.

    second screen of installation: destination directory
    Installation: it's best to keep the default destination directory, so click NEXT.

    next screen of installation: installation progress
    Wait for installation to finish.
  4. When the installation is complete, you'll see the screen that indicates installation is complete. All you need to do is click the CLOSE button.
    last screen of installation: installation is complete
    When the installation is finished, click CLOSE.

IDE Installtion/Setup

There are so many choices for the editor/IDE you might choose for coding Java programs. I will suggest two here, take your pick based on the information below, but of course if you're already more comfortable with a different editor/IDE, use it!

The two choices I have instructions for are Notepad++ and IntelliJ IDEA. Here's some information that should help you choose:

Both choices have intellisense ("helpers" that pop up as you type) and syntax highlighting (which makes the code easer to read).

Software
Notepad++ IntelliJ IDEA
Description simple editor fully featured IDE
Advantages
  • Doesn't have a lot of "stuff" (tabs, windows) all over the UI.
  • Easy to learn to use.
  • Has debugger, project management features, etc. for large projects.
  • Easy to compile/run code.
Disadvantages
  • Doesn't have a debugger or project management features, so not good for large, complex projects.
  • If you want to compile and run using the editor, there's a tedious amount of settup (it has to be done with a separate plugin that needs to be configured).
  • If you don't install the Java plugin, you still have to drop to the command-line to compile and run programs.
  • As a fully-featured IDE, there are a lot of tabs and windows and the UI can be a bit overwhelming for new programmers.

Instructions for downloading, installing, and setting up both Notepad++ and IntelliJ can be found below, but you might also consider these other popular options, instead:

There are several choices for editors and IDEs (Integrated Development Environments) that you can use. For the first Java course in your program, we're going to use a very basic and simple-to use editor called Notepad++.

Download/Install Notepad++

These instructions will take you through the installation and setup of Notepad++.

  1. Download the most recent Notepad++ version by going to Notepad++ Downloads and choosing the most recent version (the version numbers may vary from what is shown in the screen shot).

    main download page for notepad++: menu on the left and links to downloads in the main part of the screen
    Select the most recent version by clicking it. As of Winter 2021, the most recent version is "Notepad++ 7.9.2: Stand with Hong Kong".
  2. Clicking the appropriate link will give you a download page.
    page for downloading latest version (same menu on the left) - scroll down to the heading Download 64-bit x64
    Scroll down the page.
  3. Scroll down to the section titled "Download 64-bit x64" and click on the link that says "Installer". This will prompt you to save the installer file. Put it in your Downloads directory or some other directory where you can find it later.
    list of installation links: the first item has Installer link, the rest can be ignored
    Click on the "Installer" link and download the installation file.
  4. Once the file has downloaded, run it. This begins the installation. You'll first be asked to pick a language for the installation. Choose whatever language you are most comfortable with (this is just for the installation process, it doesn't change the language used in the editor). Then click OK.
    dialog with a drop-down list where you can select language, then Ok and cancel buttons
    Select a language the installer should use, then click OK
  5. The welcome screen appears and lets you know that you are about to configure your installation. Click the NEXT button.
    First screen: you're about to install Notepad++, next and cancel buttons
    Setup of the installation is about to begin: Click the NEXT button.
  6. The license agreement screen asks you to agree to the licensing for this software. This is typical and quite common. Click I AGREE to continue.
    Second screen: license agreement with Back, I agree, and Cancel buttons
    Accept the license agreement.
  7. The next screen asks you to choose a location where Notepad++ should be installed. The default value here is fine, and you shouldn't change it unless you know what you're doing. Click the NEXT button.
    Third screen: field where you can change installation folder followed by Browse button; back/next/cancel buttons at the bottom
    Leave the default destination folder and click the NEXT button.
  8. The next screen gives you an opportunity to choose which parts of the program you want to install or not install. The defaults here are fine, so you can leave them alone. Click the NEXT button.
    Fourth screen: long list of items you can choose to install or not; back/next/cancel buttons at bottom
    Leave the default list of components, just click the NEXT button.
  9. The next screen asks for a few more options. Check the box that says "Create Shortcut on Desktop" and leave the other box unchecked. Click the INSTALL button to start installing Notepad++.
    Fifth screen: checkbox to create a shortcut on the desk top; back/install/cancel buttons at bottom
    Choose whether or not you want a shortcut for Notepad++ on the desk top (I recommend you check it) and then click the INSTALL button.
  10. The last screen lets you know that the installation was completed successfully. Make sure the box "Run Notepad++..." is checked and then click FINISH.
    Last screen: has a checkbox Run Notepad++ v7.8.2 and back/finish/cancel buttons at the bottom (back/cancel are disabled)
    Make sure Run Notepad++ box is checked, then click the FINISH button.

Notepad++ starts and the change log file is loaded. You can close this file, we don't need it for anything (it's only interesting to read if you've used Notepad++ before and want to know what's different in this newest version).


big picture of Notepad++ open showing the change.log file; in this editor, open files are each in their own tab with a little X button
Notepad++ loads the change.log file when it opens. You can close that file by clicking the X in its tab.

Some of you may wish to change the font size right away before you do anything else, so you can more easily read the Notepad++ screen. To edit your font size, go to the menu bar at the top and select Settings > Style Configurator. On the right side of the screen is a drop-down where you can change the font size. If you also decide to change the font name, make sure you stick with a mono-spaced or fixed-width font like Courier New. (Personally, I prefer Ubuntu Mono or Fira Code)

Setup Notepad++

The last set of steps we need to complete today is to set up commands that will allow us to use Notepad++ to compile and execute Java programs we write. This isn't really mandatory, but it's very convenient, so we'll do it.

First, we need to install a special plugin in Notepad++ that allows us to run other programs from within Notepad++.

  1. In the menu bar at the top, select Plugins > Plugins Admin.
    showing the menus: Plugins open and showing sub menu; Plugins Admin selected
    Open the Plugins Menu and select Plugins Admin
  2. This opens the Plugins Admin window and shows you a list of available plugins. To make it easier to find the one we want, type nppexec in the "Search" field.
    plugins admin window with nppexec in search box; below that is plugins list showing NppExec checked; install button top-right
    Locate NppExec, select it, and then click the INSTALL button.
  3. You should see the plugin titled "NppExec" come into view. Check it off and then click the INSTALL button.
  4. Next, you'll receive a warning that Notepad++ needs to restart. Click YES.
    dialog: Notepad++ is about to exit; If you click YES, you will quit Notepad++ etc etc; Yes/No buttons
    Notepad++ needs to restart, so click the YES button
  5. Notepad++ should restart on its own. Once it restarts, go to the Plugins menu again. There should be a new item in the Plugins menu called "NppExec". If you don't see it, go back through the instructions above and make sure you read and followed them correctly.
  6. We are now going to add two simple scripts that compile and execute Java programs that we write.
  7. In the menu bar, select Plugins > NppExec > Execute
    showing the main Notepad++ window with Plugins menu open again, NppExec now shows as a menu item; it's selected, and Execute is selected in the NppExec sub menu
    Select Execute in the NppExec menu
  8. You should now see the Execute window. This is where you can add/modify scripts and even execute them, if you wanted to.
    the execute window has a big text area titled Command(s), a drop-down list with temporary script selected; has ok, save, and cancel buttons
    The execute window, where you can create, edit, and run scripts.
  9. The first script we'll add is the script that compiles a program. The first command in this script will move to the current working directory where our source code is saved and the second command will run the compiler to compile the source code. In the big editor area of the window, enter the following:
    cd $(FULL_CURRENT_PATH)
    javac $(FILE_NAME)
    Make sure you add the line break between the two lines of code (press the ENTER key after typing the first line). The first command changes the directory to the current one where your source file has been saved. The second comman runs the Java compiler program (javac.exe) on your current source code file. This will compile your code and show you any syntax/compiliation errors. If you have no errors, it will create the bytecode file.
  10. Save your script by clicking the SAVE button.
  11. In the text field that appears, type Compile and then click the SAVE button under the text field.
    the execute window showing the script in the Commands field and an area below where the script name has been set to Compole, and a set of buttons below that (save/delete/cancel), this area overlays the bottom part of the execute window, so if you need to go back to the execute window buttons, you'd have to click cancel first
    Save the script as "Compile"
  12. The bytecode file is the file that you can execute by telling the Java Virtual Machine (JVM) to interpret and execute each line of bytecode. This job is done with the Java interpreter program (java.exe). Let's now repeat the process to create a script that runs the Java interpreter program.
  13. Use the drop-down box at the bottom of the Execute window and select "<temporary script>".
  14. The editor is now blank (if not, delete the text that appears). Enter the code:
    cd $(FULL_CURRENT_PATH)
    java $(NAME_PART)
                                
    FOLLOW THE INSTRUCTIONS: this code is not the same as the code for the compile command!! The first line does the same thing as the first line of the previous script. It's probably not necessary most of the time, but if you compile a program, and then come back later to run it, your system directory might have changed, so it's a good idea to execute it anyway. The second line runs the interpreter program (java.exe) on the bytecode that was created from compiling the current file.
  15. Press the SAVE button to save this script.
  16. As before, in the text field, enter the script name. This one is called "Execute". Then click the SAVE button under the text field.
    the execute window again, this time showing the Execute script being saved
  17. You're done, so close the Execute window by clicking the X in the top-right or clicking the Cancel button.

We now have two scripts that can comple and execute Java programs we write. However, to run these scripts, we'd have to come back to the Execute window each time. It's more convenient to add menu items and keyboard shortcuts to run these two scripts. Let's do this next.

Setting Up Macros

  1. Using the menu bar again, go to Plugins > NppExec > Advanced Options This dialog is where we'll add the menu items for our two scripts.
    the NppExec advanced options menu; at the top, Place to the Macros Submenu is checked; below this is an empty list of menu items you can add/edit
    Check the checkbox titled "Place to the Macros submenu" (love that grammar)
  2. Near the top-left of the dialog is the heading "Menu Items *". Under this is a checkbox labeled "Place to the Macros submenu". Check this box.
  3. Don't close the dialog yet, we still have 2 more things to do. Next, we'll add the two submenu items for Compile and Execute.
  4. In the same dialog, near the bottom on the left side, you'll see an area where you can add a menu item for a specific script you created. In the "Item Name" field, enter Compile Java.
  5. In the Associated Script drop-down, select your Compile script.
  6. Then click on the Add/Modify button. You'll see your compile item appear in the box above: those are the menu items that are going to be added to Notepad++'s Macro menu.
    the same advaned options menu: bottom left there's an area with the title Menu Item; it has a field Item Name, a drop-down list Associated Script, and an Add/Modify and a Delete button; below all that, is OK and cancel buttons
    Create a menu item for "Compile Java" set to your Compile script, then add this to the list of menu items.
  7. Now let's repeat the process to create an Execute Java menu item that runs the Execute script: Go to the bottom area of the dialog and change the "Item Name" field to Execute Java. In the Associated Script drop-down list, select your Execute script.
    the same advanced options window, showing that the Compile Java item now appears in the list of menu items below the check box you checked earlier; the bottom area Menu Items has a note Rpeat for Execute, and shows the item name as Execute Java and the selected script as Execute
    The new Compile Java item now appears in the list of menu items.
  8. Click on the Add/Modify button to add your Execute Java item to the list above. You should now see the two items to compile and execute Java programs in the list.
    now both Compile Java and Execute Java items appear in the list of menu items; remember the OK button is at the very bottom of the screen
  9. Click OK to save your changes.
  10. You'll get a warning that you need to restart Notepad++ to apply your changes. Click OK in the dialog, and then shut down Notepad++ and restart it.
    dialog: NppExec Advanced Options / Notepad++ needs to restarted etc etc, OK button
    Notepad++ needs to restart: click OK then restart Notepad++
  11. Once Notepad++ has restarted, go to the Macros menu in the menu bar, you'll see 2 new items: Compile Java and Execute Java.
  12. For convenience, it would be nice to associate shortcut keys with these 2 items. You don't have to if you don't want to, but it's definitely faster to use shortcut keys once you memorize them and get used to them.
  13. In the menu bar, select Settings > Shortcut Mapper
    main Notepad++ window showing the Settings menu open, Shortcut Mapper selected
    In the Settings menu, select Shortcut Mapper
  14. In the Shortcut Mapper dialog, select the "Plugin Commands" tab along the top.
  15. To make it easier to find your menu items, type "java" in the "Filter" text field near the bottom of the dialog box. You should see both your menu items appear in the list. If you don't see them, go back and make sure you've read and followed all the instructions correctly.
    shortcut mapper window, the plugin commands tab: a huge list of all the menu items and their shortcut keys that has been filtered down to just Compile Java and Execute Java; Filter field at the bottom contains the text java;
    Type "java" in the Fitler field so you can see just the two items we added earlier.
  16. Select the Compile Java item in the list and then select the MODIFY button (or you can double-click the item). We'll set the shortcut for Compile Java to Ctrl-Shift-C
  17. In the little dialog, check off the boxes for CTRL and SHIFT, then select the letter "C" in the drop-down list. When you're finished, click OK.
    shortcut dialog has a Name field that already contains Compile Java; check boxes for CTRL (checked), ALT, and SHIFT (checked) which is followed by a drop-down list of characters (C is selected); OK and cancel buttons;
    Check CTRL, SHIFT, and select C from the drop-down list, then click OK.
  18. Make sure the message near the bottom of the screen says "No shortcut conflicts for this item". If it says anything else, you'll need to change the shortcut to something else (use whatever works for you as long as it's not an existing shortcut).
  19. Repeat for the Execute Java item: Select it and click MODIFY, or double-click the item. We'll set the shortcut to Ctrl-Shift-E, so check off the boxes for CTRL and SHIFT, then select the letter "E" in the drop-down list. When you're finished, click OK.
    same shortcut dialog, this time showing Execute Java as the Name; CTRL and SHIFT checked, E selected in the drop-down list
    Check CTRL, SHIFT, and select E from the drop-down list, then click OK.
  20. You now have menu items along with keyboard shortcuts that will allow you to compile and execute Java programs from inside Notepad++. Click the CLOSE button on the Shortcut Mapper window.
  21. Check your Macro menu now: you can see both menu items and their shortcut keys.
    main Notepad++ window showing the Macro menu open; the Compile Java and Execute Java items are showing with their keyboard shortcuts
    You should now see two new items in the Macros menu, at the bottom: Compile Java and Execute Java, with their respective shortcuts.

Let's test everything out and see if it worked.

Testing

You should already have a new file open in Notepad++, but if not, just use the NEW icon in the button bar (it's the first button) or use the File > New menu items.

In your new, empty file, copy and paste the following code:

public class Testing {

    public static void main(String[] args) {
  
        System.out.println("Hello, World!");
    }
}

Use the SAVE option (File > Save or File > Save As, or you can use the SAVE button in the button bar (it's the third button)) to save your file as Testing.java

The file name is case-sensitive: the T must be upper-case and everything else must be lowercase. You must include the lowercase .java file extension.

DO NOT save your file in the Notepad++ directory, and DO NOT save it to your Desktop!!

Take the time to go and create a directory for this course and add a "projects" subdirectory to it, and then save your file there. You will be creating several files every lesson, and it's important to keep them organized so that you can easily find them at any time.

NOTE: Changing the console font: If you find the font in the console area is too small, you can make it larger (and even change the actual font name/family. In the Notepad++ menu, select Plugins > NppExec > Change Console Font. The default font "System" has a limited size on some systems, so if you want a larger font size, just change to a different mono-spaced/fixed-width font such as Courier New, Lucida Console, Ubuntu Mono, or Fira Code. Then you can change to a larger size.

Now try your menu items:

  • First, use Macro > Compile Java or use the Ctrl-Shift-C keyboard shortcut.
  • This should compile the code you were given. The code has no errors, so you shouldn't get any (if you do, perhaps you hit a key by accident - copy and paste the code again, and don't forget to save your file before you compile).
  • You should see a little console window open along the bottom of your screen, and it should contain text such as:
    NPP_EXEC: "Compile"
    CD: C:\Users\Wendi\Google Drive\~Work\!!Winter2020\Java1\projects\_examples\Testing.java
    Current directory: C:\Users\Wendi\Google Drive\~Work\!!Winter2020\Java1\projects\_examples
    javac Testing.java
    Process started (PID=20472) >>>
    <<< Process finished (PID=20472). (Exit code 0)
    ================ READY ================

    this is just a screen shot showing the editor with the Testing.java program and the console area showing the text output from the previous figure
    The output from a successful compile.
  • If you see an error such as:
    NPP_EXEC: "Compile"
    CD: new 1
    Current directory: C:\Program Files\Notepad++
    javac new 1
    ; about to start a child process: "javac new 1"
    CreateProcess() failed with error code 2:
    The system cannot find the file specified.
    
    ================ READY ================

    It might mean that you are using an older version of Java and you need to set up some environment variables. If you're absolutely sure that you've installed the current version of Java and you see this error, ask your professor.
  • If you see anything else that doesn't match the successful compile output above, ask your instructor or professor. If you're not in class and need to contact your instructor or professor via email, be sure to send them a paste of all the output in your console window along with the code you're trying to compile. If you're receiving error messages in a dialog box, take a screen shot and attach that to your message. There are several other problems that could occur, and if you don't show your instructor or professor exactly what happened, they can't help you solve the problem.
  • If your program compiled successfully, it means you now have a bytecode file that you can execute using the Java interpreter. If you like, you can use a file management tool to browse to your current directory and see that you now have a Testing.java and a Testing.class file.
  • To execute your bytecode file, we can use the Execute Java menu item: Use Macro > Execute Java or use the Ctrl-Shift-E keyboard shortcut.
  • You should see a successful execute in the console window, including the text "Hello, World!" Your execute output should look something like this:
    NPP_EXEC: "Execute"
    CD: C:\Users\Wendi\Google Drive\~Work\!!Winter2020\Java1\projects\_examples\Testing.java
    Current directory: C:\Users\Wendi\Google Drive\~Work\!!Winter2020\Java1\projects\_examples
    java Testing
    Process started (PID=21072) >>>
    Hello, World!
    <<< Process finished (PID=21072). (Exit code 0)
    ================ READY ================

    this is just a screen shot showing the editor with the Testing.java program and the console area showing the text output from the previous figure
    The output from executing your Java program.

Installing IntelliJ IDEA by JetBrains is optional. If you've never programmed before, you might want to skip this for now and wait until you're more comfortable. You'll be using an IDE such as IntelliJ or NetBeans in term 2, so there's no rush unless you want to try something more challenging. You can always come back later in the term and install it then if you feel like you want to give it a try.

IntelliJ is an IDE (Integrated Development Environment, rather than just a simple editor like Notepad++. It has many more features and tools that are common to more intermediate and advanced application development. This is a very popular IDE for students learning Java: it's project-based, yet also very simple to use compared to more professional IDEs such as NetBeans or Eclipse.

Follow the instructions to first download, and then install IntelliJ IDEA to your machine.

  1. Go to the IntelliJ IDEA download page.
  2. Click the download button under the "Community" edition. Save the file to your computer.
    the main download page with 2 options: Ultimate (web, mobile, and enterprise development, costs $), and Community (Java, Groovy, Scala, and Android development, free, open source)
    Download the Community edition of IntelliJ IDEA
  3. Once the download is complete, locate the downloaded file and run it. If you are asked anything such as "Do you want to allow this app to make changes to your device?" just agree.
  4. Click NEXT on the opening welcome screen.
    first screen: you're about to install IntelliJ, close all other apps so you don't have to reboot later, Next and Cancel buttons
    Click NEXT on the opening welcome screen.
  5. The next screen confirms the location of your installation. The default is fine: you don't need to change anything. Click NEXT to continue.
    second screen: field where you can change destination of install files followed by Browse button; back/next/cancel buttons at bottom
    You don't need to change the install location. Click NEXT to continue.
  6. The next screen asks you to configure a couple of options for your installation:
    • Create Desktop Shortcut: unless your computer is really old, select "64 bit launcher" (if your computer is that old, you probably won't be able to use it in term 2 and should start thinking about getting a new one).
    • Create Associations: select ".java". This just means that when you double-click any .java file on your computer, it will automatically open with IntelliJ IDEA. Feel free to leave this unchecked if you prefer and you know what you're doing.
    Once you've set your options, click the NEXT button.
    third screen: shows that under Create Desktop Shortcut, 64-bit launcher is checked; also shows under Create Associations, .java is checked; everything else is unchecked; Back/next/cancel buttons at bottom
    Select 64 bit launcher and .java files, then click NEXT.
  7. The next screen asks you to choose a name for the folder in your Windows Start menu for IntelliJ IDEA. You can leave the default or change it if you want, it's up to you. As long as you know where it is in future, it doesn't matter. Click INSTALL.
    fourth screen: a field that contains the text JetBrains and below that is a long list of other application folders on your start menu; below that is the back/install/cancel buttons
    If you don't want to change the menu item in the Start menu, just click NEXT.
  8. The installation will take some time. You can watch the progress window while the software is installing.
  9. The last window confirms that your installation is finished and asks if you'd now like to run the IntelliJ IDEA program. If you're in class, you probably want to check the box. If you're at home and doing this on your own, it's up to you if you want to run IntelliJ now or not. Either way, click the FINISH button.
    last screen: a check box Run IntelliJ IDEA Community Edition with a note that you can choose to run it now or later; buttons at bottom: back (disabled), finish, cancel (disabled)
    Decide if you want to run IntelliJ IDEA now (check the box) or not (leave box unchecked). Click FINISH.

Running IntelliJ for the First Time

When you run IntelliJ for the first time, you'll be asked whether or not you want to import any settings from a previous installation. It's assumed you don't have a previous install, so just make sure "Do not import settings" is selected and click OK.


dialog: Complete Installation; radio buttons to import settings from another version or not at all (selected), OK button
You probably don't have any settings to import. Click OK.

Next, you'll be asked to agree to the JetBrains privacy policy. This is standard. Scroll down to the bottom of the policy text (the ACCEPT button will remain disabled until you do so). Click the ACCEPT button once it has become enabled.


screen showing the license agreement, you actually have to scroll down to the end or the Accept button at the bottom will not enable
Scroll to the bottom of the privacy policy to enable the button. Click ACCEPT.

The next screen asks if you would like to share your usage stats with JetBrains (this is common for many companies where they want to track how/when users use their software). Personally, I never agree to these things, but it's really up to you. Click either button, depending on your preference.


data sharing dialog: asks if you want to anonymously share your usage data, they won't share it, etc.. the usual thing; buttons are Send Usage Statistics and Don't Send (which is highlighted)
Choose whether or not you wish to share your usage statistics.

Finally, IntelliJ IDEA starts up and you are asked to choose a default theme (you can change or customize this in the settings, later). Choose whether or not you want the darker theme or the lighter theme. You won't need to change any of the other options they're going to ask you about, so once you've made a choice, click "Skip Remaining and Set Defaults" on the bottom-left of the screen.


dialog: customize IntelliJ IDEA: choose the dark theme Darcula on the left or the light theme called IntelliJ on the right; bottom left button Sip Remaining and Set Defaults; button bottom right Next Default Plugins
Choose your theme, then select SKIP REMAINING... on the bottom-left.

The splash screen appears while the program loads. When it disappears, you'll see the Welcome screen. This screen asks you what you'd like to do. We might as well start a new project!


Main IntelliJ screen showing icons beside 4 options: create new project (has an ouline around it), import project, open, check out from version control; at the bottom right are options Configure, Get Help
Click on "Create New Project".

You can create several different kinds of projects in IntelliJ. For this course, we'll primarily be creating simple Java projects. A Java project consists of one or more source code files that are then compiled into bytecode files. Bytecode files can then be run by any Java virtual machine.

After choosing to create a new project, you'll be asked what kind of project you want to create. Make sure Java is selected in the list on the left side of the screen.


new project dialog: a list of project types on the left; in the main part of the dialog, a Project SDK drop-down list (currently says NO SDK in it, which might be different on yours, followed by NEW button; below that is a list of additional libraries and frameworks you can ignore
Select a Java project, and then click NEW to select the SDK you want to use for this project.

To the right is the Project SDK field. This asks you to choose which Development Kit you want to use for your project. If it says "No SDK", you'll have to select the one you installed earlier. Click the NEW button.

A dialog opens asking you to choose the location of your SDK. You should see your C: drive listed there, so use the little tiny arrow on the left to expand it and browse to your Program Files / Java directory on your system.


file browser window showing a list of hard drives on the system, with C highlighted and a note to expand and browse to Program Files > Java
Expand the C: drive and then browse to Program Files / Java.

In the Program Files / Java directory, you should see your JDK folder, e.g. jdk-10.0.2 but the numbers might be different for you. Select that directory and then click the OK button.


list of directories and sub-directories, showing location to an older version of Java as c:\program files\java\jdk-10.0.2 and that directory is selected in the list below
Locate the JDK folder (make sure it's JDK, not JRE) and select it. Click OK.

Now you're back in the New Project dialog box. Ignore the bottom part of the screen where it asks about libraries. Click the NEXT button.

The next screen asks what template you want to use. We won't be using templates at this time so just ignore this screen. Click NEXT.

The last screen asks you to name your project and choose a project location. Earlier today you created directories/folders for your courses, including a java1/projects folder (or you might have called it prog10082 instead of java1, it doesn't matter). This is where you should store all of your projects. A single project contains multiple files, so when you make a project in IntelliJ, it will create a new directory/folder to contain all those files (this is often called the project's root). The name of your project root is the same as the name of your project.

Next, we create a name for our project. The project name is important, since that's how you'll be able to tell one project from another. Project names should be "self-documenting" (you should be able to accurately guess what the project is for just by reading the project name). In the example below, I called the project "FirstJavaProject". Enter an appropriate project name for your new project.

Next, we choose a location for our project files. Each project you create goes inside its own directory/folder. For example, if you create a project called "MyFirstProject", and you store it in your java1/projects folder, your project files should be located in the directory java1/projects/MyFirstProject directory.

The "Project Location:" field determines where your project and its files will be stored. By default, your Project Location may be listed as some other directory, but wee need to make sure we set it to our projects directory we created earlier. Also, since the project's files should go inside a FirstJavaProject directory, we'll need to create that directory, too.

Beside the "Project Location:" field, there's a small button with 3 dots (ellipsis) on it. Click that button to open the file browser.


New project dialog: two fields; first is Project name (currently 
                             populated with FirstJavaProject) and second is Project location (currently filled with 
                             c:\Users\jollymor\Documents\Semester 1\Java\projects; second field is followed by ellipses button that is outlined in red
Change the project location and add the directory for this new project: click the Ellipsis button.

Now you have a file browser dialog open. Browse to your prog10082/projects directory and select it.

Then click the "New Folder" button in the button bar at the top.


select project file directory dialog: the 5th button in the button bar is outlined in red; below that is a file browser to the /projects directory; OK and Cancel buttons at the bottom
Select your "projects" directory and click the New Folder button in the button bar.

Now a smaller dialog opens, asking you to enter a new folder name. For this example, I typed "FirstJavaProject" since that's the name I chose for this project. After you enter a folder name, click the OK button.


new folder dialog: Enter a new folder name field with the text FirstJavaProject already in it, Ok and cancel buttons below
Enter the directory/folder name for this project and click OK. Your folder name should be the same as your project name..

Now your file browser shows the new project directory inside your /projects directory. Make sure it's selected and then click OK.


back at the select project file directory dialog, the new FirstJavaProject direcgtory showing in the file browser
Make sure your new directory is selected, then click the OK button.

You should now be back at the original new project dialog, and the Project Location field has been updated to your newly created project directory.


the new project dialog from earlier, with the project location now showing c:\Users\jollymor\Documents\Semester 1\Java\projects\FirstJavaProject
Your Project Location field now contains the newly created location of your project, including your new project directory in your java1/projects folder.
Note
If you currently have another project open when you create a new project, you'll see the following dialog appear:
dialog asking if you'd like
                                 to open your new project in a new window, or the same window
This dialog asks if you'd like to open your new project in a brand new window, or use the current IntelliJ IDEA window that's already open.

Each project you are working on in IntelliJ IDEA runs in its own instance of IntelliJ. In otherwords, if you have two projects open at the same time, you'll have two IntelliJ IDEA windows: one for each project (the program is running twice at the same time).

It's up to you whether or not you want to open your new project in the current window, or a new one. If you want to see both projects at the same time, then choose "New Window". If you only want the new project to be open, then choose "This Window". You will be prompted to save any unsaved work before the old project is replaced with the new one. (Don't worry, your old project is still on your computer, it's just not open anymore. You can always open it again later.)

Once your new project is created and loaded, you'll see the Tip screen. You can close it, view the next tip, choose not to see tips on startup, etc.

Setting IntelliJ Preferences

As you're learning to work in IntelliJ, you might wish to change some of your preferences such as colours/fonts, markers, etc. To find the settings, go to the File menu and choose Settings.

Right Margin Marker

By default there should be a vertical line in your editor that shows you where column 80 is. It is standard in Java programming to make sure that lines of code do not go beyond column 80, so we need to make sure there's a visual guide there to let us know when we should press the RETURN key on a long line of code.

First, we need to make sure that guide is in fact at column 80 (often the default is set to something else).

In the settings, go to Editor > Code Style (just click on Code Style, don't expand it).

Change the following settings:

  • Hard Wrap at: 80
  • Visual Guides: 80
  • Wrap on typing: CHECKED

If you have trouble seeing the visual guide at column 80, you can change its colour by going to Editor > Colour Scheme > General. In the list in the top half of the screen, expand Editor > Guides and select "Visual Guides". To the right, you can then click the text field beside the "Foreground" check box to change the colour of the right margin marker. Unfortunately you can't change the thickness like you can in some other editors.

Theme, Fonts, and Colours

To change your default theme, go to Editor > Colour Scheme. Under Colour Scheme you'll also see several screens that allow you to customize the theme.

To change or enlarge the font, go to Editor > Font.