Created
July 17, 2024 00:58
-
-
Save hasnocool/901b2d4ef8fee97dab4947c571abd375 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# How to Write Your First "Hello, World!" Application in Java | |
## 1. Install Java Development Kit (JDK) | |
- **Download JDK:** Download the JDK suitable for your operating system from this link: [Java JDK 22 for Windows](https://download.oracle.com/java/22/latest/jdk-22_windows-x64_bin.exe). | |
- **Install JDK:** Follow the installation instructions provided after downloading. | |
## 2. Set Up Your Environment | |
- **Configure PATH:** After installing JDK, set the `PATH` environment variable to include the `bin` directory of the JDK installation. This allows you to use Java commands from the command line. | |
- On Windows: | |
1. Open Control Panel > System and Security > System > Advanced system settings. | |
2. Click on "Environment Variables." | |
3. Under "System variables," find the `PATH` variable, select it, and click "Edit." | |
4. Add the path to the `bin` directory of the JDK installation (e.g., `C:\Program Files\Java\jdk-22\bin`). | |
## 3. Write the Hello World Program | |
- **Create a directory:** Create a directory where you want to save your Java program (e.g., `HelloWorld`). | |
- **Create a Java file:** Open a text editor (e.g., Notepad, VSCode, or any other code editor) and create a new file named `HelloWorld.java`. | |
## 4. Code the Program | |
- **Write the following code in `HelloWorld.java`:** | |
```java | |
public class HelloWorld { | |
public static void main(String[] args) { | |
System.out.println("Hello, World!"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
So to people who might not know this mean download the java source development kit otherwise known as a SDK download and install the exe. Next create a file named HellowWorld.java and copy everything but ```java, this is just a way to say this code im showing you IS java, copy the rest inside the file using any editor you like. Notepad works just file, vscode is another I like. Next run javac to compile the code into a .class, next run java HellowWorld.java to see the output.
