How to run a Java program in Windows 10To run a java program in Windows 10, we need first to install Java and then set up the environment variables. To do this, follow the following steps- How to install Java?Step 1) Visit the oracle website and then click on download. ![]() Step 2) Now, on the next page, click on Accept License Agreement and download the .exe file of JDK for windows. ![]() Step 3) After downloading the file, start the installation process by clicking on the file. Step 4) Keep clicking on next and don't alter any default setting. After installation, we need to set the environment variables. How to set up environment variables?
![]()
![]()
![]() The setup of the Java environment is complete. How to run a Java program in Windows 10To understand how to run a Java program in Windows 10, we will see a simple example of a Hello World program- Step 1) Open a text editor and write the java code for the program. The program for Hello World is given below- Step 2) Save this file with the .java extension. Make sure that the name of the file should be the same as that of the public class. If the file doesn't have any public class, we can save it with any name, but after compilation, a bytecode file will be generated with the name of the class containing the main method. Step 3) Now, open the command prompt and open the directory in which we have saved our program by using the following command. ![]() In this case, the directory is desktop. Step 4) Now, run the following command to compile the Java program. ![]() Step 5) After the code is compiled, it generates a bytecode file in the same folder having the .java file with a .class extension. This is the file which is executed by the JRE. To run this file, use the following command. ![]() The output of the program will be seen on the command prompt. This is how we can run a java program in Windows 10.
Next TopicJava Tutorial
|
JavaTpoint offers too many high quality services. Mail us on h[email protected], to get more information about given services.
JavaTpoint offers college campus training on Core Java, Advance Java, .Net, Android, Hadoop, PHP, Web Technology and Python. Please mail your requirement at [email protected].
Duration: 1 week to 2 week