Made java installation conditional

There may be java installation called from different module
   which can cause duplicate declaration.
Making java installation conditional will avoid duplication.