When you open a file with a program from a file manager (or wherever) the name of the file is passed as the first argument to the program, so inside your script, the name of the file is in the variable $1 .
To make it pause, there is a read function, so
will make it wait.
This works if you run it from a command line, but if you open it from a file browser, then nothing happens, because it runs in the background. I found a line of bash script on a forum that solves this, so the complete script is:
Code: Select all
tty -s; if [ $? -ne 0 ]; then gnome-terminal -e "$0 $1"; exit; fi
java -jar $1
read -p "Press enter to continue"
Feel free to substitute gnome-terminal with something more exotic.
edit: i read batch as bash, and assumed UNIX, so yeah...that doesn't work
on windows, i think it's: