# Software Methodology Recitation 1: Getting Started with IntelliJ, GitHub, and GitHub Copilot
Welcome to the first recitation for Software Methodology! In this tutorial, we will guide you through installing IntelliJ IDEA (Community or Pro version), using GitHub for version control, and registering for GitHub Copilot.
---
## 1. Installing IntelliJ IDEA
IntelliJ IDEA is an integrated development environment (IDE) used for Java development and more. You can install either the Community Edition or the Pro version (free for students using an EDU email).
### 1.1 Downloading IntelliJ IDEA
1. Go to the [IntelliJ IDEA download page](https://www.jetbrains.com/idea/download/).
2. Choose your operating system (Windows, macOS, or Linux).
3. Select either the **Community** or **Ultimate** version.
- The **Community** version is free and includes all essential features.
- The **Ultimate** version is free for students with an EDU email (free license can be applied at [Free JetBrains Student License](https://www.jetbrains.com/community/education/#students/).
4. Click **Download**.
### 1.2 Installing IntelliJ IDEA
#### Windows:
1. Run the installer you downloaded.
2. Follow the installation prompts, choosing the default options.
3. Once installed, launch IntelliJ IDEA.
#### macOS:
1. Open the downloaded `.dmg` file.
2. Drag the IntelliJ IDEA icon into the **Applications** folder.
3. Open **IntelliJ IDEA** from the **Applications** folder.
#### Linux:
1. Extract the `.tar.gz` file you downloaded.
2. Open a terminal and navigate to the extracted directory.
3. Run `./idea.sh` to launch IntelliJ IDEA.
### 1.3 Registering for the Ultimate Edition
1. After installing IntelliJ IDEA, if you wish to use the **Ultimate** edition, click on **Activate** when prompted.
2. Choose **Log in with JetBrains Account**.
3. Sign in using your EDU email to get free access to the Ultimate version.
---
## 2. Using GitHub for Version Control (Command Line Guide)
GitHub is a powerful tool for version control and collaboration. In this section, we will focus on using GitHub through the command line to manage your repositories and projects effectively.
### 2.1 Setting Up Git Locally
Before using GitHub, you need to have Git installed on your machine. You can check if Git is already installed by running the following command:
```bash
git --version
```
If Git is not installed, follow the [Git installation guide](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git).
Once installed, set up your global configuration with your username and email (these details will be associated with your commits):
```bash
git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"
```
### 2.2 Creating a New GitHub Repository
To start version control, create a repository on GitHub:
1. Go to [GitHub](https://github.com/) and sign in.
2. Click on **New Repository**.
3. Choose a repository name, description (optional), and visibility (public or private).
4. Click **Create Repository**.
Now, you'll need to connect your local project to this repository.
### 2.3 Initializing a Local Repository
Navigate to your project directory in the terminal:
```bash
cd /path/to/your/project
```
Initialize Git in the project directory:
```bash
git init
```
This creates a `.git` folder in your project directory, which tracks changes and allows you to manage versions.
### 2.4 Adding and Committing Files
You need to add files to the staging area before committing them. This tells Git which files you want to include in your next commit.
To add all files:
```bash
git add .
```
To add specific files:
```bash
git add filename.txt
```
Once files are staged, commit them with a meaningful message:
```bash
git commit -m "Initial commit"
```
### 2.5 Connecting to GitHub Remote Repository
To link your local repository to the GitHub repository you created, add the remote URL:
```bash
git remote add origin https://github.com/your-username/your-repo-name.git
```
Verify the remote has been added by running:
```bash
git remote -v
```
### 2.6 Pushing Changes to GitHub
Now that the repository is connected, you can push your local changes to GitHub. Use the following command to push your commits to the `main` (or `master`) branch:
```bash
git push -u origin main
```
This command pushes the commits and sets the `origin` repository as the default remote for future pushes.
### 2.7 Cloning an Existing Repository
If you want to work on an existing project, you can clone a repository from GitHub.
```bash
git clone https://github.com/your-username/your-repo-name.git
```
This command will create a local copy of the repository.
### 2.8 Checking the Status of Your Repository
You can check the current status of your repository, such as which files are modified, untracked, or staged, by using:
```bash
git status
```
### 2.9 Pulling Changes from GitHub
If you’re collaborating on a project, you’ll need to pull changes from the remote repository to ensure your local version is up to date.
```bash
git pull origin main
```
This command fetches and merges changes from the remote repository into your local copy.
### 2.10 Branching and Merging
Git allows you to work on different features or fixes by creating branches. Here’s how to create a new branch:
```bash
git checkout -b feature-branch
```
After making changes and committing them, you can switch back to the main branch:
```bash
git checkout main
```
To merge the feature branch back into the main branch:
```bash
git merge feature-branch
```
### 2.11 Resolving Merge Conflicts
When merging branches, you may encounter merge conflicts if different changes were made to the same part of a file. Git will notify you of the conflict. To resolve it:
1. Open the conflicting file and decide how to integrate the changes.
2. After resolving conflicts, add the resolved file(s):
```bash
git add filename.txt
```
3. Commit the merge:
```bash
git commit -m "Resolved merge conflict"
```
### 2.12 Viewing Commit History
You can see the history of commits by running:
```bash
git log
```
This will display a list of commits, including author names and commit messages.
To view a simplified one-line version of the log:
```bash
git log --oneline
```
### 2.13 Pushing to and Pulling from Forked Repositories
If you’re contributing to an open-source project or working from a forked repository, you’ll often need to add an upstream remote in addition to your origin remote. Add the upstream repository URL like this:
```bash
git remote add upstream https://github.com/original-owner/repository.git
```
To pull changes from the original repository:
```bash
git pull upstream main
```
### 2.14 Connecting to Github with SSH(Recommended)
Please refer to [About SSH](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/about-ssh)
---
## 3. Registering for GitHub Copilot
GitHub Copilot is an AI tool that helps you write code more efficiently.
### 3.1 Signing Up for GitHub Copilot
Refer to [Apply to GitHub Education as a student](https://docs.github.com/en/education/explore-the-benefits-of-teaching-and-learning-with-github-education/github-education-for-students/apply-to-github-education-as-a-student)
### 3.2 Using GitHub Copilot in IntelliJ IDEA
1. Install the **GitHub Copilot** plugin in IntelliJ:
- Go to **File** > **Settings** > **Plugins**.
- Search for **GitHub Copilot** and click **Install**.
2. Once installed, restart IntelliJ.
3. After restarting, you will see GitHub Copilot suggestions in your code editor as you type.
---
## 4. Understanding Java, JVM, and JDK
As part of this course, you'll be using Java for your software development. To effectively work with Java, it's important to understand the following key concepts: Java, JVM (Java Virtual Machine), and JDK (Java Development Kit).
### 4.1 What is Java?
**Java** is a high-level, object-oriented programming language used for building a wide variety of applications. Whether you're developing desktop software, mobile apps, or large-scale enterprise systems, Java offers a versatile and robust platform.
- **Key Features of Java:**
- **Object-Oriented**: Everything in Java is represented as objects.
- **Platform-Independent**: Java programs can run on any operating system without modification.
- **Secure and Robust**: Java includes runtime checks, memory management, and strong type checking.
- **Multi-threaded**: Java supports concurrent execution of multiple threads, enhancing performance.
Java's most celebrated feature is its platform independence, which is achieved through the use of the JVM.
### 4.2 What is JVM (Java Virtual Machine)?
The **Java Virtual Machine (JVM)** is an integral part of Java's "write once, run anywhere" philosophy. It is the engine that allows Java programs to run on any device or operating system.
When you write Java code and compile it, the Java compiler (`javac`) translates the code into **bytecode** (platform-independent code). The JVM interprets or compiles this bytecode into machine code that can be executed by the host system.
- **How JVM Works**:
1. You write and compile Java code into **bytecode** (.class files).
2. The JVM reads and executes this bytecode, converting it into machine-specific instructions.
3. This allows the program to run on any system where the JVM is installed, ensuring platform independence.
The JVM is the foundation for running all Java applications, ensuring that they run consistently across different platforms.
### 4.3 What is JDK (Java Development Kit)?
The **Java Development Kit (JDK)** is a complete software development environment for building Java applications. It includes everything needed to develop, compile, and run Java programs.
- The JDK contains:
1. **Java Compiler (`javac`)**: Compiles Java source code into bytecode.
2. **JVM**: Executes the compiled bytecode.
3. **Libraries**: Standard Java libraries used for building Java applications.
4. **Development Tools**: Tools for debugging, profiling, and managing Java programs.
The JDK is essential for developers because it provides the compiler and libraries needed to write and build Java applications. Without the JDK, you wouldn't be able to compile Java programs or execute them.
### 4.4 Relations Between Java, JVM, and JDK
- **Java** is the programming language that you write your code in.
- **JVM** is the platform that allows your compiled Java bytecode to run on any device or operating system.
- **JDK** is the toolkit that includes both the Java compiler and the JVM, along with libraries and other development tools.
The relationship between these components is essential for understanding how Java works:
1. You write code in **Java**.
2. The **JDK** compiles your code into **bytecode**.
3. The **JVM** runs the bytecode, translating it into machine code that your operating system can execute.
---
This section gives you a foundational understanding of Java, JVM, and JDK, which are essential to Java development and will be used throughout this course.
## Conclusion
You are now set up with IntelliJ IDEA, GitHub for version control, and GitHub Copilot! These tools will enhance your development workflow, making it easier to collaborate and code efficiently. Good luck, and happy coding!
---