-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInstallJava.java
More file actions
110 lines (107 loc) · 4.12 KB
/
Copy pathInstallJava.java
File metadata and controls
110 lines (107 loc) · 4.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
package Phase0_SetupAndFirstPrograms.Installation;
/**
* <h1>Downloading and Installing Java</h1>
*
* <p>To run any Java program you need the JDK (Java Development Kit) installed on
* your machine. The JDK contains the compiler (<code>javac</code>), the runtime
* (<code>java</code>), and various development tools (<code>jar</code>,
* <code>javadoc</code>, <code>jshell</code>, etc.).</p>
*
* <h2>Step 1 — Choose a JDK Distribution</h2>
* <p>Multiple vendors ship the JDK. All of them are based on the same OpenJDK source
* code, so any of them will work:</p>
* <ul>
* <li><b>Oracle JDK</b> — https://www.oracle.com/java/technologies/downloads/</li>
* <li><b>Eclipse Temurin (Adoptium)</b> — https://adoptium.net/</li>
* <li><b>Amazon Corretto</b> — https://aws.amazon.com/corretto/</li>
* <li><b>Azul Zulu</b> — https://www.azul.com/downloads/</li>
* <li><b>Microsoft Build of OpenJDK</b> — https://learn.microsoft.com/java/openjdk/</li>
* </ul>
*
* <p>For learning, prefer an LTS (Long Term Support) version: Java 17 or Java 21.</p>
*
* <h2>Step 2 — Install</h2>
* <p>Windows:</p>
* <pre>
* 1. Download the .msi or .exe installer for your architecture (x64 / aarch64).
* 2. Run the installer (defaults are fine).
* 3. The installer usually adds Java to PATH automatically. If not, add manually:
* a. Win + R -> sysdm.cpl -> Advanced -> Environment Variables
* b. Create JAVA_HOME pointing to your JDK folder
* (e.g. C:\Program Files\Java\jdk-21).
* c. Edit PATH and add %JAVA_HOME%\bin
* </pre>
*
* <p>macOS:</p>
* <pre>
* 1. Download the .pkg installer or install via Homebrew:
* brew install --cask temurin
* 2. Verify JAVA_HOME (zsh):
* export JAVA_HOME=$(/usr/libexec/java_home -v 21)
* </pre>
*
* <p>Linux (Debian/Ubuntu):</p>
* <pre>
* sudo apt update
* sudo apt install openjdk-21-jdk
* </pre>
*
* <h2>Step 3 — Verify the Installation</h2>
* <p>Open a fresh terminal/PowerShell and run:</p>
* <pre>
* java -version
* javac -version
* </pre>
*
* <p>Expected output (versions will vary):</p>
* <pre>
* openjdk version "21.0.2" 2024-01-16 LTS
* OpenJDK Runtime Environment Temurin-21.0.2+13 (build 21.0.2+13-LTS)
* OpenJDK 64-Bit Server VM Temurin-21.0.2+13 (build 21.0.2+13-LTS, mixed mode)
*
* javac 21.0.2
* </pre>
*
* <h2>Step 4 — Pick an IDE (Optional but recommended)</h2>
* <ul>
* <li><b>IntelliJ IDEA (Community Edition is free)</b> — https://www.jetbrains.com/idea/</li>
* <li><b>Eclipse</b> — https://www.eclipse.org/downloads/</li>
* <li><b>VS Code + "Extension Pack for Java"</b> — https://code.visualstudio.com/</li>
* <li><b>Apache NetBeans</b> — https://netbeans.apache.org/</li>
* </ul>
*
* <h2>Step 5 — Compile and Run Your First Program (Manually)</h2>
* <p>Without an IDE, the workflow is:</p>
* <pre>
* javac HelloWorld.java // produces HelloWorld.class (bytecode)
* java HelloWorld // executes the bytecode in the JVM
* </pre>
*
* <p>Since Java 11 you can also run a single-file program directly without compiling:</p>
* <pre>
* java HelloWorld.java
* </pre>
*
* <h2>Troubleshooting</h2>
* <ul>
* <li><b>"java is not recognized"</b> — PATH is not set. Re-do Step 2.</li>
* <li><b>"Unsupported major.minor"</b> — Code compiled with a newer JDK than
* your runtime. Install a newer JDK or recompile with <code>--release</code>.</li>
* <li><b>Multiple Java versions</b> — Use <code>JAVA_HOME</code> to point to the
* one you want.</li>
* </ul>
*
* <p>This file is documentation only. There is nothing to execute here.</p>
*
* @author Deepak Gupta
* @version 1.0
* @since 2026-05-21
*/
public class InstallJava {
public static void main(String[] args) {
// Quickly print the active JDK location so you can verify your install.
System.out.println("java.home = " + System.getProperty("java.home"));
System.out.println("java.version = " + System.getProperty("java.version"));
System.out.println("java.vendor = " + System.getProperty("java.vendor"));
}
}