filmov
tv
Create, Compile and Execute a Simple Java Program

Показать описание
Steps to create, compile and execute a simple Java program after the Java installation, which can be done immediately after the path variable is updated with Java bin location to make sure Java is accessible across any location on the system.
Check out the article on our website for more details.
======================
As soon as we install Java on our machine and set up the required environment variables, we have to make sure if Java is accessible from anywhere on our machine. In order to ensure that, we have to create, compile and execute a simple Java program without an IDE.
In this video, let's take a look at how we can compile and execute a simple Java program using a command prompt.
Before we proceed, we have to make sure we have Java installed on our machine and the environment Path variable is set up as needed.
NOTE: We have separate videos on why to set up and how to set up the Path environment variable, which can be referred to for more details.
1. Verify the installed Java version
Open the command prompt and verify if we have Java installed using the command prompt.
Command to verify installed Java version
- java -version
Command to verify installed Java compiler version
- javac -version
2. Create a sample Java program
3. Compile the Java program
4. Execute the Java program
We can use the below command to execute the program from the command prompt, where "HelloWorld" is the program name.
We just need to provide the program name and file extension ".java" or ".class" is not required.
- java HelloWorld
Once we execute the program, it should execute the main method and print the value from the print statement we have in the main method.
======================
Happy Learning!!
Team,
Random Codez
Check out the article on our website for more details.
======================
As soon as we install Java on our machine and set up the required environment variables, we have to make sure if Java is accessible from anywhere on our machine. In order to ensure that, we have to create, compile and execute a simple Java program without an IDE.
In this video, let's take a look at how we can compile and execute a simple Java program using a command prompt.
Before we proceed, we have to make sure we have Java installed on our machine and the environment Path variable is set up as needed.
NOTE: We have separate videos on why to set up and how to set up the Path environment variable, which can be referred to for more details.
1. Verify the installed Java version
Open the command prompt and verify if we have Java installed using the command prompt.
Command to verify installed Java version
- java -version
Command to verify installed Java compiler version
- javac -version
2. Create a sample Java program
3. Compile the Java program
4. Execute the Java program
We can use the below command to execute the program from the command prompt, where "HelloWorld" is the program name.
We just need to provide the program name and file extension ".java" or ".class" is not required.
- java HelloWorld
Once we execute the program, it should execute the main method and print the value from the print statement we have in the main method.
======================
Happy Learning!!
Team,
Random Codez