Editing classpath for Compiled program

14 visualizzazioni (ultimi 30 giorni)
Jason
Jason il 23 Set 2015
Risposto: Rahul Goel il 28 Set 2015
Hello. I am using matlab to control some instrument hardware (camera , stages etc) using open source microscopy software (https://www.micro-manager.org/)
Whilst it supports the use of matlab and I have actually got it working, I want to be able to compile and hence use on a different machine which only has the MRC and not the full version of matlab. This is where I have run into a problem.
In order to use this open source software with matlab, its required to edit the class path and add the location of all the jar files from Micromanager. This can be done when the PC has matlab on, but I weant to compile and use on a PC with just the MRC, so how can I do the equivalent of including the jar files ???
Thanks Jason
For info here is the documentation summarised:
The Micro-Manager Core Java API is contained in the file MMCoreJ.jar. Any Java program (including Matlab) that wants to use the Micro-Manager API needs to put MMCoreJ.jar in its ClassPath. When CMMCore Java object is first created in the calling program it will automatically attempt to load native library MMCoreJ_wrap. This library must be visible to the Java run-time. Default locations and exact names of libraries are platform dependent.
On Windows, the native library file is MMCoreJ_wrap.dll and it must reside either in the system path or in the current working directory of the program in order to be detected by the Java run-time.
MMCore can be used in Matlab through its Java interface. After setting up the Java environment as described above, MMCoreJ.jar must be added to Matlab Java class path and the directory for the MMCore dynamic libraries (including MMCoreJ_wrap) must be added to the system path.
The instructions for doing the above (i.e. edit the class path.txt) are: 2. In Matlab command prompt
>> edit classpath.txt Add the location of all the jar files MM installed under plugins\Micro-Manager:
for example:
C:/Micro-Manager-1.4/ij.jar
C:/Micro-Manager-1.4/plugins/Micro-Manager/MMAcqEngine.jar
C:/Micro-Manager-1.4/plugins/Micro-Manager/MMCoreJ.jar
C:/Micro-Manager-1.4/plugins/Micro-Manager/MMJ_.jar
C:/Micro-Manager-1.4/plugins/Micro-Manager/clojure.jar
C:/Micro-Manager-1.4/plugins/Micro-Manager/bsh-2.0b4.jar
C:/Micro-Manager-1.4/plugins/Micro-Manager/swingx-0.9.5.jar
Note At least in recent versions of MATLAB (tested with R2013a), the file classpath.txt is automatically generated and should not be edited manually, lest it be overwritten. If classpath.txt contains a comment to that effect, use instead this command: >> edit([prefdir '/javaclasspath.txt']); The first time you edit the file, it will have to be created. After restarting MATLAB, you can check that the paths
have been included in the MATLAB classpath by typing
>> javaclasspath at the command prompt.
My issue is, I can't do this editing of the classpath etc on a machine that doesn't have matlab on, so any advice into how I can somehow include this in a compiled version of my matlab program will be greatly appreciated.
Thanks Jason

Risposte (1)

Rahul Goel
Rahul Goel il 28 Set 2015
Jason,
You can include the jar files during the execution of your application in two ways:
  1. Include the JAR files with the deployable executable: You can package the JARs with your application while compiling it using deploytool, you can add them to the "Other files" folder. This way your application, when executed on a machine with no MATLAB but just MCR, it will have all the required files to execute.
  2. Placing the files on the target machine and add them to the the path: Add the JAR files to the ‘classpath.txt’ file located in the MATLAB Compiler Runtime (MCR) directory. Once added, these files will be continued to be loaded by the deployed application from the classpath file. This file can be found at the following location:
mcrroot\toolbox\local\classpath.txt
where mcrroot is the MATLAB Compiler Runtime installation directory.
Hope this helps.

Categorie

Scopri di più su C Shared Library Integration in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by