I'd like to drop a file onto my jar and have the filename passed on to my main method as argument. I'm on OSX. How can I do that?
If the app. is deployed using Java Web Start, a file association can be declared. Double click any file of that type and the path of the file is supplied to the main(String[]).
BTW - here is a demo. of the JNLP file API. Note well the 2nd bug report, which would mean a minimum version of 1.6.0_10+ in order not to delete a file dropped on the application's icon.
To do this on OSX you might have to create an application bundle from your .jar. This process is documented pretty well at the Apple Developer Center (scroll down to "Mac OS X Application Bundles"). You can build a Java app which blends really well into the OSX desktop if you follow what they present there, and it's pretty easy.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With