I want to open a specific file-format with my own jar file. That means: I want to double-click the test.bo2 file and that should open my java program and send the path of that file (maybe as command-line argument). Is something like that possible?
At the moment I guess a .jar file is not a program, so is there a workaround to run a java file from a .exe or something like that? Any suggestions?
And, to go a step further, how can I automatically set this on the first startup?
As you are talking about ".exe" I assume you are using Windows.
You can register a new extension and the corresponding program by using
ftype
andassoc
:Open a commandline window, and type the following:
Register the new extension:
assoc .bo2=GenaeDocument
Associate the new type with a program:
ftype GenaeDocument=javaw.exe -jar \path\to\your\program.jar "%1"
You will obviously need to adjust the path to your jar file. This also assumes
javaw.exe
can be found on the path. If that is not the case, just use the full path tojavaw.exe
.After this, a doubleclick on a
.bo2
file should start your application. I assumed you are using a Swing (GUI) application, therefor the ftype is usingjavaw.exe
. If your application is a console program instead, you should usejava.exe
(Note this can be done somehow through the ConrolPanel/Explorer as well, but I find it quicker and easier using the commandline)