Compile execute Java a Program

//* W.A.P to print simple message

class simple
public static void main(String aa[])
System.out.println(“welcome in java”);

save this file as

To compile:-javac

To execute:-java simple

Output: Hello Java

Let’s look at how to save the file, compile and execute the program. Please follow the steps given below:

  1. Open notepad and add the code as above.
  2. 2.      Save the file as: simple. java.
  3. Open a command prompt window and go to the directory where you saved the class. Assume it’s C:\.
  4. Type  javac simple. java  and press enter to compile your code. If there are no errors in your code, the command prompt will take you to the next line (Assumption: The path variable is set).In this step program is compile.
  5. .Now, type java simple to run your program. In this step program is Interpreter
  6. You will be able to see ‘ Hello World ‘ printed on the window.

Comments are closed.