In this tutorial, we will discuss how to run a system command from a Java program.
If you want to check list of processes on your system and you are an Unix user, you will definitely use ps -ef
command. In the following program, we will run the command from Java program.
Retrieve System Information
To retrieve system information you may try the following code.
Check IP Address
If you want to check IP address of your local machine try the following code.
Open Notepad
If you want to open an applicatication using Java program, you may try the following.
Now, you may think that why are we going to write a complex code, where we can directly run those commands on terminal?
Here, the answer is: sometimes a program needs to be executed by some other program whithout human intervension. Thus this technique is used to automate the system.
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.