How to run a Java program on a Commandline
A command-line interface is a concept of interacting with a computer program whereby the user key in or issues commands to the program in form of lines of codes or command lines. These commands are handled by a program called a Command language interpreter or shell.
Command-line interface can also be referred to as command language interpreter (CLI), Command-line user interface, console user interface or character user interface (CUI).
Today Am going to show you how to write simple program in Java and run it on your computer command-line interface using Ubuntu. But before that, Let me give some of the importances of using Command-line interface instead of just the Graphical User Interface.
- Requires few system resources to implement
- Automation of repetitive tasks is simplified
- command-line history can be kept
- its faster when running programs as long as you've mastered the commands.
I won't be taking you to how to install text editors, but if you go to the official websites of these text editors, you will be able to download them. Most of them are usually free from open source.
Now lets go to how to install Java jdk in you ubuntu or any linux os and how to run your first program on command- line interface.
- From Terminal install openjdk
sudo apt-get install openjdk-8-jdk
2. Write your program and save the file name as anything. for example mine have saved as Number.java3. The next step is to compile your program from terminal
javac Number.java
After compilation another file will be created with extension .class i.e Number.class
4. Lastly we run the program
java Number
thank you!!!!!
Comments
Post a Comment