Java rpath problem

Moderator: Moderator

Java rpath problem

Postby riknik » Sat Nov 03, 2018 10:42 am

Since upgrading the MacOS to 10.13.6 I had to update ForexConnect (I chose 1.5 stable build), but then my Java program wouldn't run because I kept getting loader errors that it couldn't find the @rpath relative dynamic libraries. I fixed that by moving all the dylib files it complained about down into the same folder as fxcore2.jar. But what is the correct way to do this, because I shouldn't have to be moving dylib files around.

I'm using Eclipse to build my jar file, and it includes the dylib files in the jar, so Eclipse finds everything correctly. Is there some classpath or other runtime parameter I need to pass to Java in order for @rpath to be set to find the dylibs as they were distributed? I'm hoping if I can set that to resolve the loader issue, I will no longer need to include the dylib files in my jar, that would be a bonus.

Thanks,
Rik
riknik
 
Posts: 2
Joined: Sat Nov 03, 2018 10:16 am

Re: Java rpath problem

Postby JuliaS » Thu Nov 15, 2018 11:34 am

Hi Rik,

There are two ways for working with ForexConnect in Eclipse:

    1. Create lib folder in the Eclipse project directory and copy content of the ForexConnectAPI-1.5.0-Darwin-x86_64/lib and ForexConnectAPI-1.5.0-Darwin-x86_64/lib/java to the folder.
    2. Update content of the Package Explorer.
    3. Add the fxcore2.jar to build path.
    4. Specify the lib folder as Native Library Location: right click on fxcore2.jar -> Build Path -> Configure Build Path -> Java Build Path -> Libraries -> JRE System Library -> Native Library Location -> specify path to the lib folder.

Or, If you want to keep the same layout as in the ForexConnectAPI-1.5.0-Darwin-x86_64/lib folder:
    1. Create lib folder in the Eclipse project directory and copy content of the ForexConnectAPI-1.5.0-Darwin-x86_64/lib to the folder.
    2. Update content of the Package Explorer.
    3. Add the fxcore2.jar to build path.
    4. In Run Configuration -> Arguments add -Djava.library.path=.:./java.
    5. In Run Configuration -> Working Directory -> Other type ${workspace_loc:Test/lib}.

fxcore2.jar uses all the dylib (fxcore2.jar is just a wrapper around them), so if you do not include the dylib in your jar, you will need to distribute the dylib with your jar.
If you do not want to include dylib in your jar uncheck them in the Export window.

@rapth defined as '.' and '..' for the libfxcore2.dylib and as '.' for other libraries. Path calculated from the JVM working directory.
So, the easiest way would be distribute your application with the content of the ForexConnectAPI-1.5.0-Darwin-x86_64/lib and ForexConnectAPI-1.5.0-Darwin-x86_64/lib/java to the directory where your JAR is located.
JuliaS
 
Posts: 16
Joined: Wed Jan 25, 2017 11:19 am

Re: Java rpath problem

Postby riknik » Sun Nov 18, 2018 9:23 pm

what a great reply! You really covered it, thanks!
riknik
 
Posts: 2
Joined: Sat Nov 03, 2018 10:16 am


Return to ForexConnect API

Who is online

Users browsing this forum: No registered users and 4 guests