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 directorydir
on Windows Command Promptls -a
displays all contents including hidden files
cd
- Change directorycd ..
moves one directory upcd ~
moves directly to home directory
clear
- Clear the screencls
on WindowsCommand-K
shortcut on MacOS
Working with Directories and Files
mkdir
- Create a directorytouch
- Creates a file- On Windows, use
echo.
ortype nul >
instead
- On Windows, use
rm
- Remove filesdel
on Windows
rm -r
- Remove directoriesrmdir
on Windows
cp
- Copy filesmv
- 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 completionAlt+Enter
- Show intention actions and quick-fixesCtrl+/
- Comment/uncomment lineShift+F10
- RunShift+F9
- DebugCtrl+N
- Navigate to classCtrl+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
- Write code in
.java
files - Compile using
javac
to bytecode (.class
files) - 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
- Open your terminal and navigate to your home directory.
- Create a new directory called
java_practice
. - Navigate into this directory.
- Create a file named
Notes.txt
. - List all files in the directory to confirm it was created.
- Create a subdirectory called
projects
. - Move the
Notes.txt
file into theprojects
directory.
IntelliJ IDEA Practice
- Download and install IntelliJ IDEA if you haven't already.
- Create a new Java project.
- Create a new Java class called
HelloJava
. - Write a simple program that prints "I'm learning Java!" to the console.
- Run the program to verify it works.
- Practice using keyboard shortcuts for code completion and navigation.
Additional Resources
Check Your Understanding
Review the following questions to assess your understanding of the module's key concepts:
- What command would you use to navigate to your home directory from any location?
- What is the purpose of the
javac
command? - Name three advantages of using an IDE like IntelliJ IDEA over a simple text editor.
- How would you create a new directory and immediately navigate into it using command line?
- 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.