[zeromq-dev] Question on connecting a C++ model to a Java model via Python uzing ZeroMQ

Sara Rimer sara.p.rimer at gmail.com
Fri Apr 29 01:24:18 CEST 2016


Ok, so I ran the
mvn test
and it everything was okay. I was originally trying to rebuild some basic
ZeroMQ programs using Java just to make sure it worked (my preferred
language is Python). But while the programs would compile, they wouldn't
run. That is when I went back to looking for tutorials and came across one
that used local_lat as an example, which thanks to your advice I abandoned
trying it.

Thus, I retried building hwClient.java and hwServer.java and I finally got
them to work! My issue was pointing to the correct classpaths (which I am
not quite used to doing in Java), and also adding in this (
-Djava.library.path=/usr/local/lib), but I don't really understand what the
"-Djava" command does).

Anyway, I had to add the following paths so my command looked like this:

java -cp
./:/usr/local/share/java/zmq.jar:/home/sara/Applications/zeromq/jzmq/jzmq-jni/src/main/c++/zmq.jar
-Djava.library.path=/usr/local/lib hwClient

The Java program that I have built that I am trying to implement ZeroMQ
with I have built within Eclipse. So I am not really used to working with
Java via the terminal. Thus, I was wondering how I can I run the command
above via Eclipse? That is, if you are familiar with Eclipse, how to I add
these classpaths?
-cp
./:/usr/local/share/java/zmq.jar:/home/sara/Applications/zeromq/jzmq/jzmq-jni/src/main/c++/zmq.jar

And then how do I implement the following command in Eclipse?
-Djava.library.path=/usr/local/lib hwClient

​Thank you all. I appreciate your help.

Sincerely,
Sara​


On Wed, Apr 27, 2016 at 9:35 PM, Stephen Riesenberg <
stephen.riesenberg at gmail.com> wrote:

> Sara,
>
> While I've done quite a bit of working with jzmq on my local machine, I've
> rarely run the local_lat program that's used as an example on the
> documentation page for the java binding. So, I may be off a bit, but I
> think you would need to build the C++ project in the
> jzmq/builds/msvc/local_lat to have that class available. Possibly at one
> time it was included in the jar, but that may have changed and it looks
> like it isn't any longer.
>
> Perhaps try running the following (assuming you have maven installed) in
> the local directory where you downloaded and built jzmq:
>
> mvn test
>
>
> Another option is the JeroMQ test suite, which includes several of the
> guide examples, which also requires you to download and set up the project
> locally (using maven). Or skip it and drop these classes into your own
> project (
> https://github.com/sjohnr/jeromq/blob/develop/src/test/java/guide/hwclient.java
> ,
> https://github.com/sjohnr/jeromq/blob/develop/src/test/java/guide/hwserver.java
> ).
>
> Or try running a minimal example of your own within your own project.
>
> Hope that helps.
>
> On Wed, Apr 27, 2016 at 7:55 PM, Sara Rimer <sara.p.rimer at gmail.com>
> wrote:
>
>> Hi everyone,
>>
>> I am finally getting back to this part of my project. So I think the
>> issue is that I just can't get ZeroMQ to work with Java on my machine. I
>> have tried JeroMQ as well. I have been following this guide:
>> http://zeromq.org/bindings:java and when I try
>>
>> $ java -cp /usr/local/share/java/zmq.jar:. local_lat tcp://127.0.0.1:5000 1 100
>>
>> I get this error
>>
>> Error: Could not find or load main class local_lat
>>
>> I think I have just not found a good guide for how to set up ZeroMQ for
>> Java on Linux 12.04. Any suggestions?
>>
>> Thank you.
>>
>> Sincerely,
>> Sara
>>
>> On Mon, Mar 28, 2016 at 8:30 PM, Stephen Riesenberg <
>> stephen.riesenberg at gmail.com> wrote:
>>
>>> Sara,
>>>
>>> How far have you gotten in your effort? Do you have an example class?
>>> What issues did you run into? What requirements do you have for your
>>> API? Is it files, or just data you are sending back and forth between these
>>> two environments?
>>>
>>> Sorry for so many questions, but I bet with a few details we can get you
>>> pointed in the right direction. Sounds like an interesting project!
>>>
>>> On Friday, March 25, 2016, Sara Rimer <sara.p.rimer at gmail.com> wrote:
>>>
>>>> Hello,
>>>>
>>>> This is most likely a very basic usage of ZeroMQ, but I am a
>>>> computational engineer and I am trying to connect a hydraulic model written
>>>> in C++ to a decision tree model written in Java. I would like to send data
>>>> files back and forth between the two programs. I am using ZeroMQ for this.
>>>> And I have gotten ZeroMQ to work via Python no problem (which I am planning
>>>> on using for my C++ model which I run via a bash script). However, I am
>>>> having difficulty interfacing it with Java. I was planning on just creating
>>>> a class in Java that is solely used to interface with ZeroMQ. Does anyone
>>>> have any suggestions?
>>>>
>>>> Thanks,
>>>> Sara
>>>>
>>>>
>>>>
>>>>
>>> _______________________________________________
>>> zeromq-dev mailing list
>>> zeromq-dev at lists.zeromq.org
>>> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>>>
>>>
>>
>>
>> --
>> Sara Rimer
>> University of Michigan Graduate Student
>> Department of Civil and Environmental Engineering
>> srimer at umich.edu
>> sara.p.rimer at gmail.com
>> 269.483.6334
>>
>>
>>
>>
>>
>> _______________________________________________
>> zeromq-dev mailing list
>> zeromq-dev at lists.zeromq.org
>> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>>
>
>
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>



-- 
Sara Rimer
University of Michigan Graduate Student
Department of Civil and Environmental Engineering
srimer at umich.edu
sara.p.rimer at gmail.com
269.483.6334
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20160428/136699f7/attachment.htm>


More information about the zeromq-dev mailing list