1.
Create a text document, write your code in it
and save it as “.java” file.
2.
To compile the java file go to dos prompt. Go to
Run and type cmd click ok.
3.
Go to the directory where file is saved.
4.
Set path of java compiler so that dos prompt
will find it.
4.1. Go
to computer right click and click on properties
4.2. Click advanced settings
4.3. Click
environment variables
4.4. Edit path and at the end of the path put a
semicolon(;) and write path of your jdk bin after semi colon and click ok
path of your jdk
put a semi colon and copy that path in system variable value
If path is not set dos will not be able to
find the java compiler and will get a message.
5.
Once the path is set run your java file using
the command- javac filename.java
6.
Your file is compiled and .class file is created which is platform
independent.
7.
Now you can see the output of your file using
the command- java classname.
While compiling your file compile your .java file
and when you run your file run it with the classname without extensions, eg.
java Helloworld
No comments:
Post a Comment