I finally managed to get this working. Just followed the instructions on the website:
These are the 5 steps:
1. create java class
2. give execute permissions on java
3. create function to run cmd
4. grant execute on function to public
5. run the command.
I have copied all the long SQL commands in a text file to make things easier.
An example of command execution is:
The website also talks about some cool hacks to get the output of the command through OOB channels.