There is no advantage with using Java. Anything you can do with Java, you can do with PHP and other languages.
At one time many web gurus thought Java was going to be the dominant web programming language, but it is slow and is a resource pig.
Java works well for building internal (enterprise) corporate systems. IMHO, it is not a good choice for building web sites.
If you look into the history of Java, the language was originally developed to be used as a home controller. It was supposed to power an electronic home. It failed at that.
In the late 1990s, it was touted as the best programming language for the web. It failed at that.
It finally found a home with enterprise systems. It works well for that.
"Democracy is two wolves and a lamb voting on what to have for lunch. Liberty is a well-armed lamb contesting the vote." -- Benjamin Franklin