Traditionally, with Java web applications, we build a Web Application Archive (WAR), or Enterprise Application Archive (EAR), and deploy them in servers. Before we can deploy a WAR on the server, we need a web server or an application server installed on the server. The application server would be on top of the Java instance installed on the server. So, we need Java and an application (or web server) installed on the machine before we can deploy our application.
The following diagram shows an example of an installation in Linux: