Search code examples
javafile-association

Utilising a file association in a Java application


I am in the process of writing a cross platform Swing based application in which I want to utilize a file association which has been registered with the OS.

So iv got to the point where I can click on a file and my app loads, but what I need to know is how I can get my application to know where the file is that launched it and then query the contents.

Is there something further I have to do with the file association registration? Or can Java do this for me?


Solution

  • I'm not positive, but I'd expect that the name of the file you're processing by file click will end up in the arguments to your main() method. Have you tried/checked that?