JAVA Tutorials

Write your First Basic Java Program

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.

Facebook Comments
Tags

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Back to top button
Close
Close