Made java installation conditional

There may be java installation called from different module.
This can cause duplicate declaration.