You can't associate file extensions to trigger a .jar
file on Windows. The only file types you can trigger on Windows are .exe
, .pif
, .com
, .bat
, .cmd
, so instead of triggering the .jar
file, you can trigger a .bat
file, which then launches the .jar
file.
Create a y.bat
file and place it next to your y.jar
file and write the following code inside it:
@echo off
title y
start javaw -jar "C:\Users\SomeUsername\Desktop\y.jar" %1
You can change the title
and y.jar
path as you please, just remember that the path need to be the absolute path. Though the real keyword here is %1
, that is the actual path, of the file you clicked.
You can get the value of any parameter using a % followed by it's numerical position on the command line. The first item passed is always %1 the second item is always %2 and so on
%* in a batch script refers to all the arguments (e.g. %1 %2 %3 %4 %5 ...%255)
Now you can simply right-click on any .abt
file and press "Open With...", remember to check "Use this app for all .abt files" and then just browse for the y.bat
and click "Open". Now each time you double-click a .abt
file it will launch your .jar
program.
Additionally I've written this post (Associate File Extension with Java Application) after writing this answer.