I want to add arguments to my Java application before i run it. I want to be able do somthing like:
public static void main(String args[])
{
String document = args[0];
new DocumentViewer(document);
}
I want to do somthing like when you click on a Word document it opens up the document by itself, you dont have to open word and then click open. Does anyone know how to add arguments? All relevant answers are appriciated!
To associate your program with a file extension, so that it is automatically called, you have to configure your Desktop Environment (Linux) or Windows (Windows) (I don’t know for OSX).
I don’t have it in my head, but as far as I remember, you combine the extension, xtx for example, with a starting command, like
If you have or can have more arguments (mark multiple files, and drag them to your starter) you can, afaik, go up to %9%:
%1% is for the first param and so on.
There is nothing you can do from Java, except catching those parameter, what you already do.
On Linux, your starter is very similar: