Menu
gps garage
  • Home
  • Health
  • Nature
  • IT & Software
  • Science
  • Technology
  • Offers
  • Write for Us
    • Privacy Policy
    • Terms & Conditions
gps garage
structure for java program

How to run your 1st java program with ease?

Posted on April 26, 2021May 6, 2021

Run Your 1st Java Program

When Java program is written on notepad, then .java is given with this extension. The file name of java is the name of the class. If a java file has more than one class, then the class that contains the main method, then the name of that class is the name of the file. The name of any class and the name of the file are the first character; occurs in uppercase.

For example, HelloProgram.java

To run your 1st java program first set the path for java compiler. To set the path first press “windows+r” key and you get the following –

Now type the cmd in the text field and press ok and you will get the following-

Now create a java folder on the desktop or where you want. Then using cd command reach to that folder (see figure below). Type ‘dir’ command to see the files that are inside the java directory (folder).

Now we set the path to run the java file. To set path just open JDK directory in c drive and then go to the bin folder (figure below)

Now copy the path from address bar (figure below)

To set path just paste the copied content by right clicks and paste (figure below). Command below:

set path= “C:\jdk-16\bin”;

To check that the path is set or not just type command path and enter and your path is visible on the cmd.

Now we type and save our HelloProgram as HelloProgram.java (figure below)

Once program is saved it is visible in your java folder (created to save the programs) (figure below)

Now to compile the java program just type the ‘javac’ command like below:

run your 1st java program

Once java file is compiled a HelloProgram.class file is visible in your java folder. (Figure below)

Now to run the java program we use “java” command (see figure below)

 

Output: Once your program successfully run then you get the following output.

run your 1st java program

 

Must Read – Java Program Structure

Download JDK

 

Categories

  • Education
  • Entertainment
  • Features
  • Game
  • Health
  • IT & Software
  • Must Read
  • Nature
  • News
  • Offers
  • Popular News
  • Science
  • Technology
  • Trending News
  • World

Archives

  • March 2025
  • January 2025
  • December 2024
  • September 2022
  • July 2021
  • June 2021
  • May 2021
  • April 2021
  • March 2021

Categories

  • Education
  • Entertainment
  • Features
  • Game
  • Health
  • IT & Software
  • Must Read
  • Nature
  • News
  • Offers
  • Popular News
  • Science
  • Technology
  • Trending News
  • World

Meta

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org
©2025 GPS Garage | Powered by SuperbThemes