how to open mp3,jpg or any other media or text file

hi,i'm writing a program that accepts the file path to a file. what i'd like to know is how do i open that file,
where it be a mp3 file that would open in media player or a doc file that would open in MS word or
any other file and the corresponding program to open it.