Welcome to the Object Oriented Programming in Java repository! This repository contains notes and code examples organized into units, helping you understand and practice Java concepts step-by-step.
The repository is organized into four main folders, each representing a unit of the course:
- Unit1/
NOTES.md– Markdown notes covering fundamental OOP in Java concepts.code/– Example Java programs (subfolders).
- Unit2/
NOTES.mdcode/
- Unit3/
NOTES.mdcode/
- Unit4/
NOTES.mdcode/
Additionally, you will find:
- .vsode/, .idea/ – Contains setup files for Visual Studio Code (VS Code) and IntelliJ IDEA to help you load and run the Java projects in each of the subfolders.
-
Browse the Notes
Within each unit folder, find theNOTES.mdMarkdown (.md) files. These notes will guide you through the theoretical concepts of each unit. -
Explore the Code Examples
In thecodesubfolder under each unit, you will find practical Java examples illustrating the concepts discussed in the notes. Each example might be in its own subfolder. -
Run and Experiment
Feel free to modify the example code or create your own Java files to practice. Instructions on setting up Java and running the code from the command line are provided below. -
Setup Files
- If you prefer using VS Code, refer to the files in the
setup/vscodedirectory. - If you prefer using IntelliJ IDEA, refer to the files in the
setup/ideadirectory.
- If you prefer using VS Code, refer to the files in the
-
Prerequisites Before you begin, ensure that the following tools are installed on your system:
- Java Development Kit (JDK): Version 11 or higher.
- Git: For version control.
- Gradle: Although we'll use the Gradle Wrapper, having Gradle installed can be helpful.
- Text Editor or IDE: Such as VS Code, IntelliJ IDEA, or Eclipse.
You have two main options for installing the Java Development Kit (JDK): Oracle JDK or OpenJDK. Both will allow you to compile and run Java programs.
OpenJDK is open-source and is typically the easiest to install on Ubuntu:
sudo apt update
sudo apt install openjdk-21-jdk(You can replace 21 with the version you need, e.g., openjdk-11-jdk.)
If you prefer Oracle’s official JDK:
- Download the
.debpackage from the Oracle Official Website. - Navigate to the directory where the package is saved:
cd /path/to/download - Install the package:
sudo dpkg -i <oracle-jdk-package>.deb
- Verify installation:
You should see the Oracle JDK version displayed.
java -version
After installing Java (whether OpenJDK or Oracle JDK), you can compile and run the example code from the command line. Below is a general step-by-step guide:
-
Open a Terminal: Navigate (
cd) to the directory containing the Java files you want to compile. For instance:cd /path/to/Unit1/code/Example1 -
Compile the Java File(s):
javac Main.java
javacis the Java compiler.- This will generate one or more
.classfiles in the same directory.
-
Run the Java Program:
java Main
- Make sure Main is the class that contains the
public static void main(String[] args)method.
- Make sure Main is the class that contains the
-
Passing Arguments (Optional):
If your program requires command-line arguments, you can pass them like so:java Main arg1 arg2
- Install the Java Extension Pack from the VS Code Marketplace.
- Copy or clone this repository to your local machine.
- Open the root of this repository with VS Code.
- The extension pack will detect the Java projects, and you can start editing, compiling, and debugging Java code directly within VS Code.
- Install IntelliJ IDEA (Community Edition is sufficient).
- Clone this repository to your local machine.
- From the IntelliJ IDEA Welcome screen, select Open or Import.
- Navigate to this repository’s root folder (or a specific unit’s
codesubfolder) and import it as a Maven/Gradle project if applicable, or simply as a Java project. - IntelliJ will automatically configure the project’s libraries and dependencies.
If you find any issues or want to suggest improvements:
- Open an Issue: Describe the problem or the idea you have.
- Submit a Pull Request: Fork this repository, make changes, and submit a pull request for review.
This repository is intended for educational purposes. Feel free to fork and modify for your personal study or classroom use. If you plan to use it beyond that, please check the specific licensing details or contact the authors of the original work.
Happy Coding!
For any questions or clarifications regarding the course materials, feel free to reach out to me at a_abhijith@cb.amrita.edu or open an issue in this repository. Enjoy learning Object Oriented Programming in Java!