Search code examples
javadrag-and-dropcommand-line-arguments

Drag&Drop file to jar file (in Windows Explorer)


I have written a Java application, that analyzes some data from within a zip file.

I can pass the filename as command line argument to the application (java -jar myapp.jar fileToAnalyze.zip) and it does what it is supposed to do.

Unfortunately it is somehow complicated to call the application via command line. I would like to simply drag the ZIP file to the jar and let it start. I have absolutely no idea how to do this. Could you please give some hints?

Thanks in advance.


Solution

  • It seems that windows doesn't allow file drops on jar files. But short of finding a solution for that you could instantiate a JFrame when you run your jar file and make it listen for dropped zip files on that instead.

    An example of that can be found here.