Search code examples
javafilefilereaderdefault-programs

Making a default reader to open all files of a fixed extention (e.g. *.txt)


I am coding a JAVA reader to read .txt files as a substitution for notepad. Now, the problem is, I want to set that program to be the default program to open all .txt files. Now, how the program will distinguish which file I am opening via the program? I don't want to make a program that will first open JFileChooser and will make the user to open that file via JFileChooser. I just want to make a notepad in java that will open .txt files like notepad does. When I will click on a file say, *.txt, it will use my program to open that file and my program will show the chars of that file.


Solution

  • I didn't test it, but I would expect that if you create a Jar file from your sources, and you let your OS point to that file to open *.txt files, then the absolute path of the file to open would be in your main's "String[] args". Can you make a quick test?