8 Steps to run Java Program using command prompt
Step 1: Write a Java code using notepad
For example:-
class HelloWorld
{
public static void main(String args[])
{
System.out.println("Hello Java");
}
}
Step 2: Save it as HelloWorld.java (For example : It is saved in C:\Users\comp\Java Practiced program).
Step 3: Set environment variable .
Right Click on MyComputer -> Properties -> Advanced System settings -> Inside Advanced tab
Click Environment variables -> Inside System Vaiables click New -> Give variable name (For example var) -> Give variable value. It is path in your system where java compiler is available (For example variable value :C:\Program Files\Java\jdk1.6.0_23\bin ). Inside bin javac is Java compiler.
Click Ok.
Step 4: Go to command prompt by using start->Run->cmd OR start-> type cmd in search program and file.
Press Enter.
Step 5:Use the following command to go the folder where previous Java program is stored.
cd C:\Users\comp\Java Practiced program
Press enter
Step 6 : Set path of Compiler. It is path in your system where java compiler is available
For example, set path=C:\Program Files\Java\jdk1.6.0_23\bin;
Press enter
Step 7: Write following command for compilation of program
javac HelloWorld.java
Press Enter
Step 8: To run program use following command
java HelloWorld
Now output is shown : Hello Java
If any query mail Please mail me on vaishalichaudhari1992@gmail.com or comment it....
0 comments:
Post a Comment