So, have a Basic Example of JAVA Program :
We need two software to generate a Java Program->
- First one is the Java SE Development Kit
- The second one is a Text Editor
- For this example, weāll use a notepad.
- A notepad is a simple editor involved with the Windows Operating System.Ā
- We can use another text editor like NotePad++
Here are the few steps to the Compile and Run Java program:
Step 1)Ā Go to the Start menu and Open notepad by selecting Programs > Accessories > Notepad.
Step 2)Ā Make a code for the first basic program.
- Letās declare a class with the name Test.
- Then declare the main method,Ā i.e., public static void main(String args[]){
- Now write System.out.println (“First Program”);Ā
- The above line displays the text First Program.
Step 3)Ā Now, save the file asĀ Basicprogram.javaĀ and make sure to save the file in the working folderĀ C:\workspace
Step 4)Ā Now, go and open the command prompt.Ā
Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Go to Directory path C:\workspace.Ā
Ā Then, compile the above code using the command,
Step 5)Ā If you look in your working folder, you can see that a file namedĀ FirstProgram.classĀ has been created.
Step 6) Now, execute the code and enter the java command, followed by the class name.
Ā Ā Ā Ā Ā Ā Ā Ā So, the expected output should be the āFirst Program.ā
Note: Ā As we say,Ā Java is case sensitive Programming language.Ā
So, all the code, commands, and file names should are used in the consistent casing.
Letās have an example on case sensitive:
int demo=1;
int DEMO=1;
*These are completely different variables.
Ā Step 7)Ā Now, copy the code and paste the same code in IDE like we say Eclipse the compiling and execution is done with the click of a button.