Although accessing EJB using dependency injection is the easiest way, it works only if the container manages the class that accesses the EJB. If you want to access EJB from a POJO that is not a managed bean, then dependency injection will not work. Another scenario where dependency injection does not work is when EJB is deployed in a separate JVM (could be on a remote server). In such cases, you will have to access the EJB using JNDI lookup (visit https://docs.oracle.com/javase/tutorial/jndi/ for more information on JNDI).
JEE applications could be packaged in Enterprise Application aRchive (EAR), which contains a .jar file for EJBs and a .war file for web applications (and a lib folder containing ...