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:
  1. Compile log without error  ->

  1. 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.
Note: Every time you make a change in your program the file needs to be compiled. 

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 –
  1. IntelliJ IDEA
  2. Eclipse
  3. Android Studio(SDK also required)
  4. NetBeans
  5. Apache Maven
  6. Gradle

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.



Comments

  1. Hey there! Please share and comment if you liked this article. With love from AJAY SINGH RANA.

    ReplyDelete

Post a Comment

Popular posts from this blog

How to earn Google Play Cash ?

HOW TO HIDE A FILE IN ANDROID WITHOUT A VAULT?

Android apps to run Python Codes