Open any kind of application with BASH

I have made a Java program that could open any application. Suppose there is a file name “*.jpg”, the it would allow the OS to recognize the type of application and then open the default application. Another example: Suppose the file’s name is “*.flv”, then it would open up the default media player just like when you click an icon in nautilus but the only difference was that it was in command line. Here is the java program for that: