In Java, the import statement is used to import a class in a package. For example, the following command imports the "HelloWorldRemote" class in the "com.ejb.view" package. If the class in the package cannot be located, to the left of the import statement will be a red X.
The packages and classes being imported will be in a JAR file. When there is a red X to the left of the import statement, this usually means that the JAR file that contains the package and class has not been added to the Java Build Path in Eclipse, or the JAR does not contain the class. For example, let's say EJBTest.jar contains the "com.ejb.view" package and the "HelloWorldRemote" class. The JAR can be added to the Java Build Path.
If the package and class are found in the JAR, then red X should no longer be displayed to the left of the import statement, and the class can be used in your Java project.
If the class in the package cannot be located when the app is deployed to the application server, and exception should be caught in the application servers log. Here is an example of WebSphere's SystemOut.log showing that the com.ejb.view.HelloWorldRemote package class could not be found.
00000093 ServletWrappe E com.ibm.ws.webcontainer.servlet.ServletWrapper service Uncaught service() exception thrown by servlet ejb.client.EJBServlet: java.lang.NoClassDefFoundError: com.ejb.view.HelloWorldRemote Caused by: java.lang.ClassNotFoundException: com.ejb.view.HelloWorldRemote
When deploying your app to an application server, such as JBoss, Tomcat, or WebSphere, you can either place the JAR in the /WEB-INF/lib folder of your application, or if the JAR is located on the application server, you can use the application servers JAR. If you have numerous apps on your application server that will be using the same JAR, it probably makes sense to not include the JAR in the apps /WEB-INF/lib directory, and to instead configure the application server to be able to provide the app with the JAR.
Export JAR to /WEB-INF/lib
If you want the JAR to be placed in your apps /WEB-INF/lib folder when the WAR is compiled, you'll want to add a Deployment Assembly. When the WAR is deployed to your application server, the JAR will be in the /WEB-INF/lib directory of your app.
Now, the JAR will contain "Publish/export dependency: /WEB-INF/lib.
Get JAR from Application Server
As an example, following is how to configure a JVM on WebSphere to use a class in a JAR.
Configure the JVM to use the EJB shared library.