1

Context:

My aim is to simply run a RabbitMQ receiver (in Java) that would accept and print the messages to the console. I have another service that would be sending the messages to this receiver. Everything happens with the default config (ports, localhost, etc.).

Steps followed:

  1. I am trying to follow this RabbitMQ tutorial.

  2. As mentioned towards the end of the tutorial, to compile the Recv.java application, I run the following command (similar to the one given):
    javac -cp amqp-client-5.5.1.jar Recv.java

  3. Note that I manually downloaded the amqp-client-5.5.1.jar file and have copied it to /Library/Java/Extensions as mentioned in this SO answer.

Error:

When I try to run my application, I get many errors like below:

Recv.java:1: error: package com.rabbitmq.client does not exist
import com.rabbitmq.client.Channel;
//------------------------^
Recv.java:2: error: package com.rabbitmq.client does not exist
import com.rabbitmq.client.Connection;
//------------------------^
Recv.java:3: error: package com.rabbitmq.client does not exist
import com.rabbitmq.client.ConnectionFactory;
//------------------------^
Recv.java:4: error: package com.rabbitmq.client does not exist
import com.rabbitmq.client.DeliverCallback;
...

Obviously, it is unable to find the packages to run. However, the tutorial does not elaborate much and so I am unable to proceed. I tried running the RabbitMQ Java client, but its README.md does not have how to run instructions either. Oh, there was one other SO answer which talked about some rabbitmq-client.jar file, but that is not mentioned anywhere in the tutorial or the README.md, so I am not sure I that answer was helpful.

How could I run this?

halfer
  • 19,824
  • 17
  • 99
  • 186
J. Doe
  • 1,291
  • 2
  • 10
  • 19

1 Answers1

0

Add the JAR to the classpath. If the target/ folder contains the Recv.class file, do this:

$ javac -cp amqp-client-5.5.1.jar:target Recv
  • So as per my comment below the question, I have added the .jar file to the classpath. However I am unable to see any .class file in the target/ folder. So how do I run the command? Alternatively, could you please let me know how to run the rabbiqmq-java-client (because the README.MD file does not have any instructions about how to run it). – J. Doe Apr 29 '19 at 14:38