An android device can be controlled by a pc using adb and fastboot commands. So I need to make a software using java to run these adb fastboot commands.
You can just print adb commands on the console to execute them.
For java, execute system process
Most if not all languages allow you to execute commands from your code, so if you are familiar with adb, you can build your commands easily.