Can I compile an object that uses the BLP function in the Datafeed Toolbox to extract data from the Bloomberg database?

1 view (last 30 days)
Can I compile an object that uses the BLP function in the Datafeed Toolbox to extract data from the Bloomberg database? If so, can I deploy an executable file of this type to another user with Bloomberg connectivity and Matlab Runtime installed? Where should such a user install "blpapi3.jar"?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 10 Mar 2022
Edited: MathWorks Support Team on 11 Mar 2022
1) An object can be compiled which uses the BLP function in the Datafeed Toolbox to extract data from the Bloomberg database. Given below is the list of functions which cannot be compiled with the Datafeed Toolbox:
-    Any UIs
-    "dftool"
For more information regarding the Toolboxes supported by MATLAB compiler, please refer to the link below: 
An executable file of this type can also be deployed to another machine with Bloomberg connectivity and MATLAB Runtime installed. A wrapper .M file that creates an object of the class can be added as the main file. Any class dependencies will get picked up in "deploytool" through dependency analysis.
As for the JAR file, the “blpapi3.jar” can be installed by including it as an additional file in "deploytool" or with a ‘-a’ flag, if the command "mcc" is used to compile the application. In the target machine, "javaaddpath" should be used to add this JAR file to the dynamic path. ‘Target machine’ refers to the machine which does not have MATLAB on it, but has access to Bloomberg service. "javaaddpath" is used to add entries to dynamic Java class path.
Packaging the JAR file along with the executable would ensure that the JAR file gets extracted along with the other dependent files in the MCR (MATLAB Runtime Component) cache. For more information regarding MCR cache, please refer to the link below:
The packaged files will get extracted to the temp location (mcrcachedir). If the MCR location has been set to a different directory using the ‘MCR_CACHE_ROOT’ environment variable, then the packaged  files will be in that directory.
To make the application work on the target machine, the path of the JAR file needs to be added to the dynamic Java path of the target machine. This operation of adding the path can be performed by including the following code snippet in the function that is to be compiled:
if (isdeployed)
        javaaddpath(fullfile(ctfroot, blpapi3.jar))
end
In the above snippet of code, "fullfile" builds full file name from the folders and file names specified as parameters.
If warning messages are received, saying the JAR file is already specified on static java path, this could be due to the fact that the path of the JAR file is hard-coded in the ‘javaclasspath.txt’ file in the ‘prefdir’ directory, thereby adding it to the static classpath. When the application is created with a JAR file attached to it and then deployed to a target machine, the hard-coded JAR file path is also added to the static ‘javaclasspath’ of the machine where the application is deployed. It is important to note that the static path of the JAR file would not be the actual path where the JAR file gets extracted in the target machine. The JAR file gets extracted to the relative ‘ctfroot’ path on the target machine.
So to ensure that the application in the target machine accesses the correct path of the JAR file, the path of the JAR file in the ‘javaclasspath.txt’ file needs to be deleted in the machine where the code is compiled. 
The ‘javaclasspath.txt’ file location can be found by executing the following command on the MATLAB command prompt:
prefdir
This command outputs the path of the folder containing preferences, history, and layout files in MATLAB.
Please refer to the blog in the link below for a detailed explanation on path management in deployed application: 

More Answers (0)

Categories

Find more on Java Package Integration in Help Center and File Exchange

Products


Release

R2015a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!