Follow below step by step process:-
1. Create a folder
2. Using Notepad or notepad+ text editor, create a small Java file
1. Create a folder
C:\java program
.2. Using Notepad or notepad+ text editor, create a small Java file
HelloWorld.java
public class HelloWorld { public static void main(String[] args) { System.out.println("Hello, World!"); } }
Save your file as
HelloWorld.java
in java program folder.
3. Click on start and type command prompt in search and press enter. Command Prompt will open
4. Run Command Prompt
- Type C:\> cd \java program
This makes C:\java program the current directory.
- Type C:\> \java program\dir
This directory show
HelloWorld.java
among the files.
- Type C:\> \java program\set path=%path%;C:\Program Files\Java\jdk1.8.0_144\bin
This tells the system where to find JDK programs. Setting path be carefull otherwise system got crash
- C:\java program> javac HelloWorld.java
This runs javac.exe
, the compiler. If any error please check text file and set path
-Type C:\> \java program\dir
javac has created the
HelloWorld.class
file. You should see HelloWorld.java
and HelloWorld.class
among the files in same location.-Type C:\java program> java HelloWorldThis runs the Java interpreter. You should see the program output:
Hello, World!
No comments:
Post a Comment