Module 1: Command-line and IDE Basics

Module Overview

In this module, you'll learn how to navigate a command-line shell, iterate through an edit-build-test cycle locally from the command-line, and develop code using an Integrated Development Environment (IDE).

Learning Objectives

  • Navigate a command-line shell.
  • Iterate through an edit-build-test cycle locally from the command-line.
  • Develop code locally from an IDE.

Content

Command Line and IDE Basics

Command Line Essentials

The command line is a text-based interface to interact with your computer. Different operating systems offer different terminal options:

  • MacOS: Terminal (Bash, Zsh)
  • Windows: Command Prompt, Git Bash, PowerShell

Basic Navigation Commands

  • pwd - Shows current working directory (Print Working Directory)
  • ls - Lists current contents of working directory
    • dir on Windows Command Prompt
    • ls -a displays all contents including hidden files
  • cd - Change directory
    • cd .. moves one directory up
    • cd ~ moves directly to home directory
  • clear - Clear the screen
    • cls on Windows
    • Command-K shortcut on MacOS

Working with Directories and Files

  • mkdir - Create a directory
  • touch - Creates a file
    • On Windows, use echo. or type nul > instead
  • rm - Remove files
    • del on Windows
  • rm -r - Remove directories
    • rmdir on Windows
  • cp - Copy files
  • mv - Move files or rename them

IntelliJ IDEA Basics

IntelliJ IDEA is a powerful Java IDE that provides advanced code editing features, debugging tools, and project organization capabilities.

Key Features

  • Project Structure - Organize your code files and resources
  • Code Completion - Intelligent suggestions as you type
  • Refactoring Tools - Easily restructure your code
  • Debugging - Step through code execution to find bugs
  • Version Control Integration - Work with Git and other VCS

Essential Keyboard Shortcuts

  • Ctrl+Space - Basic code completion
  • Alt+Enter - Show intention actions and quick-fixes
  • Ctrl+/ - Comment/uncomment line
  • Shift+F10 - Run
  • Shift+F9 - Debug
  • Ctrl+N - Navigate to class
  • Ctrl+Shift+N - Navigate to file

Note: On Mac, typically use Cmd instead of Ctrl.

Java Compilation Process

Understanding how Java code is compiled and executed is essential for efficient development:

The Process

  1. Write code in .java files
  2. Compile using javac to bytecode (.class files)
  3. Run using the Java Virtual Machine (JVM) with java command

Example Compilation Workflow

// 1. Create a simple Java file named HelloWorld.java
public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello, World!");
    }
}

// 2. Compile from command line
javac HelloWorld.java

// 3. Run the compiled program
java HelloWorld

When using IntelliJ IDEA, this process is handled automatically when you click Run or press Shift+F10.

Practice Activities

Command Line Practice

  1. Open your terminal and navigate to your home directory.
  2. Create a new directory called java_practice.
  3. Navigate into this directory.
  4. Create a file named Notes.txt.
  5. List all files in the directory to confirm it was created.
  6. Create a subdirectory called projects.
  7. Move the Notes.txt file into the projects directory.

IntelliJ IDEA Practice

  1. Download and install IntelliJ IDEA if you haven't already.
  2. Create a new Java project.
  3. Create a new Java class called HelloJava.
  4. Write a simple program that prints "I'm learning Java!" to the console.
  5. Run the program to verify it works.
  6. Practice using keyboard shortcuts for code completion and navigation.

Guided Project

Additional Resources

Check Your Understanding

Review the following questions to assess your understanding of the module's key concepts:

  1. What command would you use to navigate to your home directory from any location?
  2. What is the purpose of the javac command?
  3. Name three advantages of using an IDE like IntelliJ IDEA over a simple text editor.
  4. How would you create a new directory and immediately navigate into it using command line?
  5. Explain the basic Java compilation process in your own words.

These questions are designed to help you identify areas where you might need additional study before proceeding to the next module.