Easiest way to make .jar files being executable with double click

Some time before I was fine with just running them in a console, with java -jar /filepath, but I’ve noticed that at the university during a practice work with a uni’s PCs, Ubuntu is running them with simply a double click, and as I understood it’s using this package - jarwrapper.
And also there’s this way to do it - https://wiki.archlinux.org/title/Binfmt_misc_for_Java

But I found it’s far more simpler to just create a simple .sh script with literally 2 lines of code which are doing the job done and then just to make this script associated with a .jar files.

Strangely, on the first pages of Google, I didn’t found someone with as simple as mine solution.

#!/bin/bash

file="$1"
java -jar "$file"
1 Like

Shorter, does the same thing:

#!/bin/sh
java -jar "$1"
1 Like