Organizing your project directory for the client

This is what your projects/advice directory should look like after we write and compile the client code.

image with no caption

The Client Code (AdviceClient.java)

image with no caption

Compile the client:

image with no caption

The client needs access to the two interfaces (Advice, AdviceHome) and the two stub classes that implement those interfaces. They’re both in the client JAR the server made, but we can’t compile the client without them. The cleanest way is to add them to the classpath at compile-time, using the -classpath compiler flag.

Run the client!

image with no caption

At runtime, the client still needs access to the two interfaces (Advice, AdviceHome) and the two stub classes that implement those interfaces. They’re both in the client JAR the server made, we have to add them to the classpath. The best way is to use the -cp compiler flag.

Note: For now, the client must be on the same physical machine as the server. Later, we’ll see how to change this, and run the client against a J2EE server on a different machine.

image with no caption

Get Head First EJB now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.