Home‎ > ‎Applied Core Java‎ > ‎Introduction‎ > ‎

FirstHello.java


Program :

Step 1 - Coding

Create a text file FirstHello.java  and copy below contents.

/**

 * A program that prints 'Hello Java' string at standard output console
 * Java training example source code developed by SunilOS.

 *
 * Copyright (c) 2008 SunilOS
 * @version 1.0
 *
 */

public class FirstHello {

    public static void main(String[] args) {
        System.out.println("Hello Java");

    }

}

Step 2 - Deployment

  1. Create a folder 'c:\sunilos'. 
  2. Create or copy FirstHello.java  into 'c:\sunilos' folder.
  3. Open your command prompt and go to  'c:\sunilos'
  4. Compile FirstHello.java with help of 
    • javac FirstHello.java command.  Command will create class file in the same folder.
  5. Congratulations!! your First Java program is ready to serve.

Step 3 - Testing

  1. Make sure you are on Command Prompt under c:\sunilos directory
  2. Now start your First java program from command prompt with help of 
    • java FirstHello command.

Output


It will show a message.
Hello java...

Troubleshooting


Error : C:\sunilos>javac FirstHello.java
'javac' is not recognized as an internal or external command,
operable program or batch file.
Resolution : Check your PATH environment variable. JAVA_HOME is not in PATH. Set path by
         SET PATH=%JAVA_HOME%/bin;%PATH%


Video

Run JAVA Program from Command Prompt



Run Java Program from MyEclipse



<<Previous | Next>>
ċ
FirstHello.java
(0k)
Mahima Hardia,
Aug 20, 2011, 2:37 AM
Comments