Getting Started
JDK Installation on Windows
- Visit JDK Download: Go to the Java SE Downloads page.
- License Agreement: Accept the Oracle License Agreement.
- Download for Windows: Click the Download link for the Windows
.exe
file. - Run Installer: Execute the downloaded installer.
- Installation Steps: Follow the on-screen instructions.
- Installation Path: The default installation path is
C:\Program Files\Java\jdk-<FEATURE>
.
Visual Studio Code Installation on Windows
- Download VS Code: Get the Visual Studio Code installer for Windows.
- Run Installer: Execute the downloaded installer.
- Installation Path: The default path is
C:\Users\{Username}\AppData\Local\Programs\Microsoft VS Code
. - Java Extension Pack: Install the Extension Pack for Java in VS Code.
Create a 'Hello World' Project
- Open Visual Studio Code: Start VS Code.
- Command Palette: Open it by pressing
Ctrl + Shift + P
. - Create Java Project: Type
Java: Create Java Project
and select it. - Project Setup: Choose
No build tools
. - Project Name: Name your project
HelloWorld
and choose a save location.
Understanding the Project Hierarchy
HelloWorld/
(Main Folder): The root folder of the project.README.md
: Provides an overview of the project..vscode/
: Contains VS Code-specific configurations.lib/
: Stores external libraries and dependencies.src/
: Holds the main source code files.
Key Files and Folders
settings.json
: Configuration settings for the Java project in VS Code.App.java
: The main Java class file for the application.
settings.json Explained
{
"java.project.sourcePaths": ["src"],
"java.project.outputPath": "bin",
"java.project.referencedLibraries": ["lib/**/*.jar"]
}
- Source Paths: Specifies the directory (
src
) containing Java source files. - Output Path: Defines
bin
as the directory for compiled Java files. - Referenced Libraries: Includes all
.jar
files in thelib
folder.
App.java Explained
public class App {
public static void main(String[] args) throws Exception {
System.out.println("Hello, World!");
}
}
Code Explanation:
public class App
: Defines a public class namedApp
.public static void main(String[] args) throws Exception
: The program's entry point.System.out.println("Hello, World!");
: Prints "Hello, World!" to the console.
Running 'Hello World'
Run the Program:
- Right-click in the
App.java
file. - Select
Run Java
. - The output "Hello, World!" appears in VS Code's terminal.
Assignments
Overview
You are to modify the App.java
file to achieve different levels of output complexity. Choose between easy, medium, and hard assignments as per your confidence level.
Easy Assignment
- Objective: Modify
App.java
to output "Hello, Java!". - Hint: Focus on changing the string within the
System.out.println
method. - Expected Output:
Medium Assignment
- Objective: Alter
App.java
to print "Hello," on one line and "Java!!" on the next. - Expected Output:
Hard Assignment
- Objective: Modify
App.java
to output "Hello," on the first line, "Java" on the second line, and "World!!" on the third line. - Expected Output: