Using wildcards in the sudoers file
sudoers file, you can use wildcards (*), thus creating the possibility to run a script with arguments.
I tested it with a shockingly simple python script. In the
sudoers file I had to use the absolute path to
/usr/bin/python in the line of the sudoers file:
jacob ALL=NOPASSWD: /usr/bin/python /home/jacob/Bureaublad/pscript_1.py*
Then my (python script) code was:
s1 = sys.argv
s2 = sys.argv
Then I ran in a terminal:
~$ sudo python '/home/jacob/Bureaublad/pscript_1.py' monkey banana
without asking for my password.
Similarly, you should be able to achieve what you want by adding the following line to the
<your_username> ALL=NOPASSWD: /path/to/java <your_script>*
And run the script by:
sudo java <script> <args>
and you will not be asked for your password.
An interesting source on how to use the
sudoers file might be this one.