HOW TO RUN JAVA PROGRAM THROUGH COMMAND PROMPT WITHOUT AN IDE?
Hey Guys! Welcome
back. Here I am with another article. Today I’ am gonna discuss how to run your
Java program with the help of command prompt without any IDE (Integrated
Development Environment).
I will show you by
compiling the following code ->
Here we go š -
1.
Firstly
check if you have a JDK distribution installed or not (If you are sure that it
is installed then directly jump to the second step). If you are not sure than
open command prompt. And type :
java –version
See the picture
->
And hit enter. If it
tells the version like the following it means it’s installed.
Else if it shows the
following text it means it’s not installed.
If it is not installed
then click here to install one.
Check again after
installing to make it sure that it is installed properly.
2.
Now
write the following command to compile the java program (I wish you might be
aware that a program code needs to be compiled before run).
Syntax:
javac file_location_with_file_name
Example:
javac C:\Users\Admin\Desktop\helloworld.java
See the picture->
*
file_location is the directory of the file (example: C:\Users\Admin\Desktop\ helloworld.java is a file location with file name at it’s
last i.e. helloworld.java).
Now, hit Enter.
If you pass a wrong
file location it will show the following output:
Else if you passed
the right file location then the command prompt prints the compile log:
- Compile log without error ->
- Compile log with error ->
It also indicates
the type and position of the error.
If it doesn’t show
any error then move to step 3 else eradicate the error and compile again.
3.
After a
successful compile the program is ready to run. Write the following command:
Syntax:
java –ea
file_location
Example:
java –ea C:\Users\Admin\Desktop\helloworld.java
See the picture->
Hit Enter and it
will show the output on the screen as follows->
Well, this was the
way to run your java program with command prompt. But I would suggest you to
use an IDE as it enable you with much more features. Few IDE for java are –
Whatever
you like to do is up to youJ, I wish you will write great codes. Happy coding J.
Will be back again
with another useful article, by the time goodbye friends.
Hey there! Please share and comment if you liked this article. With love from AJAY SINGH RANA.
ReplyDelete