6. Basic Commands for command prompt and Basic java program

Command Line Interface

Commands for Using Command Prompt -

Here are some common commands used in the Command Prompt:

  1. 'dir'

    • Lists the contents of the current directory.
    • Example: 'dir'

  2. 'cls'

    • Clears the screen.
    • Example: 'cls'

  3. 'cd'

    • Changes the directory from the current folder to a specified folder.
    • Example: 'cd foldername'

  4. 'cd..'

    • Moves up one directory level from the current folder to the parent folder.
    • Example: 'cd..'

  5. 'drive name:'

    • Changes the drive.
    • Example: ' C:'

  6. 'mkdir' or 'md'

    • Creates a new folder in the current directory.
    • Example: 'mkdir foldername' or 'md foldername'

  7. 'javac -version'

    • Checks the version of the Java compiler.
    • Example: 'javac -version'

  8. 'java -version'

    • Checks the version of the Java Virtual Machine (JVM).
    • Example: 'java -version'

These commands will help you navigate and manage directories, check Java versions, and perform various tasks in the Command Prompt.


Basic Java Program

class hello
          {      // Class block starts from here.
                   public static void main(string[]args)
                         {          // Method block starts from here.
                                    System.out.println("Hello world !!") ;
                         }           // Method block ends here.
           }      // Class block ends here.


This is a basic java program to print Hello world!!  where we have class name as hello.

Explanation of program

  1. Class Declaration

    • class hello { ... }
    • Defines a class named hello. In Java, every application begins with a class definition.

  2. Main Method

    • public static void main(String[] args) { ... }
    • The main method is the entry point of any Java application. It is a static method, which means it belongs to the class rather than instances of the class.

  3. Print Statement

    • System.out.println("Hello world!!");
    • This line prints the text "Hello world!!" to the console. The System.out.println method is used to print output in Java.

Comments