Table of Contents
Write and Run Java Code on the Computer for the First Time is easier to understand when the core ideas are paired with practical examples. The sections below explain the topic clearly, highlight useful steps, and point out details that can prevent common errors.
After you've installed Java and set up a path on your computer, you need to know how to run a simple Java code on your computer. Here, we will try to write the first Java program, as well as the commands to run this program in cmd.
Be sure to read and follow the instructions Here so that the process of running the code won't fail: Download and install Java on the computer.
The first Java program
Yes, the most classic code when learning every major programming language is Hello or Hello World.
public class JavaFirst { /* ?ây là ch??ng trình Java ??u tiên c?a tôi. * Nó s? in 'Hello World' ra màn hình */ public static void main ( String [] args ) { System . out . println ( "Hello World by Tipsmake" ); // in Hello World } }
Do not wonder if you do not understand anything, just copy the one, then it will be fine.

Run Java code on the computer
Now see how to save the file, compile and run the Java program, make sure you follow the steps below:
- Make sure you have installed Java JDK and tweaked PATH on the computer.
- Open Notepad and paste the code above.
- Save the file as: JavaFirst.java
- Open cmd and go to the directory where you saved the JavaFirst.java file, assuming cmd is in drive C, you save the file in folder E: Java, enter the following command to switch to the folder E: Java.
cd d / E: Java

5. To compile the Java code you entered:
javac JavaFirst.java
Then press Enter. If there are no errors in the code, cmd will take you to the new line. Now if you only install Java JDK without setting PATH, you will receive an error message. If the file name you set is different (other than the class name), you will receive an error message.
6. To run the program, enter the following command:
java JavaFirst
FAQ
What should you know about the first Java program?
Yes, the most classic code when learning every major programming language is Hello or Hello World.
What should you know about run Java code on the computer?
Now see how to save the file, compile and run the Java program, make sure you follow the steps below:
What is Write and Run Java Code on the Computer for the First Time?
After you've installed Java and set up a path on your computer, you need to know how to run a simple Java code on your computer.
Reader Comments 0
Sign in with email or Google to join the discussion.