Some PCs might have Java already installed. To check if you have Java installed on a Windows PC, search in the start bar for Java or type the following in Command Prompt (cmd.exe):
To install Java on Windows: Go to "System Properties" (Can be found on Control Panel > System and Security > System > Advanced System Settings) Click on the "Environment variables" button under the "Advanced" tab Then, select the "Path" variable in System variables and click on the "Edit" button Click on the "New" button and add the path where Java is installed, followed by \bin. By default, Java is installed in C:\Program Files\Java\jdk-11.0.1 (If nothing else was specified when you installed it). In that case, You will have to add a new path with: C:\Program Files\Java\jdk-11.0.1\bin Then, click "OK", and save the settings At last, open Command Prompt (cmd.exe) and type java -version to see if Java is running on your machine
In Java, every application begins with a class name, and that class must match the filename. Let's create our first Java file, called Main.java, which can be done in any text editor (like Notepad). The file should contain a "Hello World" message, which is written with the following code: This will compile your code. 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: