Some PCs might have Java already installed.
To check if you have Java installed on a Windows PC, type this following in Command Prompt (cmd.exe):
C:\Users\Your Name>java -version
If Java is installed in your system, you will see something like this (depending on version) in the Command Promt:
java version "11.0.1" 2018-10-16 LTS Java(TM) SE Runtime Environment 18.9 (build 11.0.1+13-LTS) Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.1+13-LTS, mixed mode)
You can write Java code in a text editor, but it's also convenient to use Integrated Development Environments like IntelliJ IDEA, NetBeans, or Eclipse, especially for larger Java projects.
To install Java on Windows:
In Java, every application starts with a class name that must match the filename.
To create our first Java file named "Main.java," you can use a simple text editor like Notepad
In this file, write a "Hello World" message using the following code:
public class Main { public static void main(String[] args) { System.out.println("Hello World"); } }
If the code isn't clear to you right now, that's okay; we'll explain it later. For now, let's focus on running it.
If there are no errors in the code, the command prompt will take you to the next line. Now, type "java Main" to run the file:
Great job! You've successfully created and run your first Java program!