Class vs package vs module vs component vs container vs service vs platform in Java world [closed]

class A class is the blueprint for creating objects in class-based object-oriented programming; you should learn the basics of OOP and understand what an object is, what a class is, what is inheritance, polymorphism, encapsulation before learning anything else about Java.

package A package is a namespace; it let's you handle naming conflicts. It basically lets you have two classes named Employee, if they are in different packages.

module It probably refers to the way that Java libraries are distributed and used - JAR, WAR, EAR.

component Can be regarded as the base class of GUI in AWT (or JComponent in Swing) or can be seen as a type of EJB - a POJO (Plain Old Java Object) that meets some requirements; it is possible to have other meanings and depends on context.

container In enterprise application you obviously use some libraries and Java EE eventually; the thing about the Java EE library is that it only provides the API interface and not implementation. Then, the application you have written and built is deployed into a container server which comes with the implementation of the Java EE API. There are two types of containers: web containers (only comes to implementation of web specific technologies) and full Java EE containers (comes with implementation of web and other Java EE technologies - naming services, persistence, transactions etc).

service There is no special meaning in Java. It may be related to web services which basically provide a high-level approach of Inter Process Communication over network.

platform There is no special meaning in Java; it can be seen as the underlying developing platform (Windows, Linux) or with the cloud trend it may refer to Platform-as-a-Service where the cloud provider comes with the infrastructure and other basic software (OS, database, container).


  • Class:
    it is normal java file which has .java extension and that contains all object, method or etc which are necessary to make application and also implements or extends other object or method from other file.

  • Package: It is bunch of class(.java) file which is separate by their function or their name. so it is also help for naming.

  • Module: Large applications are typically built in several parts, which are more tightly connected to each other than to the outside. Therefore, one would like to give these parts more access to each other than the outside world has. One might also want these parts reused at many points in the system without worrying about the synchronization of shared data. this part is called module in java. WAR, jar etc are called module in java language.

  • Component: A component is an identifiable part of a larger program or construction. Usually, a component provides a particular function or group of related functions. In object-oriented programming and distributed object technology, a component is a reusable program building block that can be combined with other components in the same or other computers in a distributed network to form an application. A component runs within a context called a container.

  • Container: A component runs within a context called a container.The container is an important component of Web applications in Java-based Java EE technology. It is responsible for maintaining the individual components on the server side, which include Java servlets, Java server pages(JSP) and Java server faces(JSF). How the services will be provided and accessed is determined by a contract, which is an agreement between the Web application and the container. This provides a considerable amount of security in the Java EE framework because the client applications are unaware of the existence of the container and therefore it cannot be accessed directly. Thus, the Web container is responsible for initializing Web application components and invoking client requests on the components.

  • Service: Service is an evolution of distributed computing based on the request/reply design paradigm for synchronous and asynchronous applications. An application's business logic or individual functions are modularized and presented as services for consumer/client applications.

  • Framework: Frameworks impose a definite structure on the code that uses them, whereas libraries do not. In software, framework is set of reusable software program that forms the basis for an application. Frameworks helps the programmers to build the application quickly. Earlier it was very hard to develop complex web applications. Now its very easy to develop such application using different kinds of frameworks such as Struts, Struts 2, Hibernate, JSF, Spring etc.

  • Platform: Platform refers to the entire Java development and execution environment from Sun. Java programs are executed by a runtime engine (the Java Virtual Machine) that resides in the target computer. Since Java contains its own operating environment, it has been dubbed a "platform" in contrast to other programming languages that, once compiled, run by themselves. See Java, Java 2, Java Virtual Machine and Java Runtime Environment.