This blog post is basically on a simple approach I attempted to make a task we were given as lab assignment a little simpler than it looks.

This semester (1st semester of 3rd Year) we have to follow the subject 'Distributed Systems'. A small introduction to distributed systems would look like:

A distributed system is a model in which components located on networked computers communicate and coordinate their actions by passing messages. – wiki

I would not be talking on distributed systems in this blog, but let me share with you all the simple approach I made to make things a little bit easier for me trying to test/run my application for the assignment. To note, we were given an assignment 'Java RMI with Callback functions' and to run this application we should compile all .java classes first, then generate stubs using the rmic compiler, then starting the rmiregistry, and then comes starting the server and running clients and stuff. Basically, if you know what you are doing, and you could make the program work the way you want, or in-fact in the way your lecturer wants, you are good. For you would be made to do all these tasks just once only. But in a scenario where you have to try to make it work, which would result in many failed test runs, you would have to go through hideous repetitions of the steps of several compilations and service initializations. Let me take you straight to the shell script.

#!/bin/bash

echo -e "\n\nCompiling .java files"
javac *.java

echo -e "\n\nRMI Compiling ..."
rmic TemperatureMonitor
rmic TemperatureSensorServer

echo -e "\n\nStarting rmiregistry"
rmiregistry
  • javac *.java – compiles all the java files.
  • rmic statements generates the required stubs.
  • rmiregistry initiates the registry for binding remote objects.

This is just a very simple scenario, where shell scripting can be used to automate tasks. Indeed it can be used to perform more complex tasks.