0

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.

Christian Rockrohr
  • 1,045
  • 1
  • 14
  • 29

2 Answers2

0

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.

Community
  • 1
  • 1
LCE
  • 874
  • 8
  • 15
0

It still (10/2021) seems that Windows does not allow this.

What you can do:

  • create a batch file with the java call to your program. This will open a command line window along with your program and might seem ugly.
  • create a desktop link to your java.exe (or javaw.exe). In the properties of the link, add "-jar YourJarFile.jar" as command line arguments to the link target.

In both cases, Windows will send the dropped file to your program as command line arguments.

no-kul
  • 1