I had to prepend 

bot.perspectiveByLabel("Java").activate();

in order to switch to Java perspective otherwise package explorer isn't found

view() is deprecated hence better use 

bot.viewByTitle("Package Explorer").show();