All IT Courses 50% Off
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.

Write your First Basic Java 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,

Write your First Basic Java Program

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.

Write your First Basic Java Program

Facebook Comments
Tags

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.

Related Articles

Back to top button
Close
Close

Get Java Training Online
Course Now at 50%OFF!

Offer valid for 1st 20 seats only, Hurry up!!

You have successfully subscribed to the newsletter

There was an error while trying to send your request. Please try again.

H2kinfosys will use this information to be in touch with you for providing updates.

Get Python Course
worth 499$ for FREE!

Offer valid for 1st 20 seats only, Hurry up!!

You have successfully subscribed to the newsletter

There was an error while trying to send your request. Please try again.

H2kinfosys Blog will use the information you provide on this form to be in touch with you and to provide updates and marketing.