> Now what's the outer problem that makes you need sudo?
Create the '/usr/local/share/java' directory if it isn't already
created.

It was more easy to make:
-------------
dir_root = /usr/local/share/java
FileUtils.mkdir_p(dir_root) unless File.exist?(dir_root)
-------------

but I'm supposed that in this case I'll have to make:
-------------
if not File.exist?(dir_root)
   system("sudo mkdir -p #{dir_root}")
end
-------------