0

I currently use Matlab and the Ocean Optics Omnidriver (http://oceanoptics.com/faq/controlling-usb-spectrometers-omnidriver-matlab/) to control a USB spectrometer on a windows 7 machine, and I'm trying to migrate to Octave.

Omnidriver is written in Java, and there is reasonable documentation for Matlab. After installing the driver the relevant Matlab commands are:

>> javaaddpath('C:\Program Files\Ocean Optics\OmniDriver\OOI_HOME\OmniDriver.jar');
>> wrapper = com.oceanoptics.omnidriver.api.wrapper.Wrapper();
>> wrapper.openAllSpectrometers();

the first line seems to translate directly once the '\' are replaced with '/', and I can see the file added to the dynamic java path.

The second line directly throws "error: 'com' undefined", but replacing with;

>> wrapper = javaObject ("com.oceanoptics.omnidriver.api.wrapper.Wrapper")

seems to work.

The third line directly then throws the error; "error: [java] java.lang.NoClassDefFoundError: Could not initialize class com.oceanoptics.uniusb.UniUSB"

which is where I'm stuck at the moment (UniUSB.jar is a file in OOI_HOME). On the OceanOptics page linked above, what I'm assuming is the same error is listed as a common problem caused by Matlab failing to find the required DLLs, and the solution is given as adding the path to OOI_HOME to matlabroot/toolbox/local/librarypath.txt

I'm assuming that if I can find the equivalent octave file then adding the path should solve my problem, but I can't find the file.

Any advice would be greatly appreciated!

hichris123
  • 10,145
  • 15
  • 56
  • 70
ChrisB
  • 1

1 Answers1

0

The code

>> javaaddpath('C:\Program Files\Ocean Optics\OmniDriver\OOI_HOME\OmniDriver.jar');
>> wrapper = com.oceanoptics.omnidriver.api.wrapper.Wrapper();
>> wrapper.openAllSpectrometers();

translates better with:

wrapper = javaObject ("com.oceanoptics.omnidriver.api.wrapper.Wrapper");
javaMethod ("openAllSpectrometers", wrapper);

Note that this is also valid Matlab syntax.

Another thing is that Octave handles java classes better if they are on the static classic path. So I'd recommend you add the path to OmniDriver.jar to your javaclasspath.txt file. See the manual for details.

carandraug
  • 12,938
  • 1
  • 26
  • 38
  • Thanks for the quick response, unfortunately even with that syntax I still get the same error when trying the final line with the dynamic class path. I'm also having weird difficulty assigning the static class path. I've added the .txt file to the directory indicated by 'which javaclasspath', but Octave still says that static java class path is empty. Is there a specific syntax or header that is required? I'm using Octave 4.0.0 if that is relevant. – ChrisB Jun 05 '15 at 17:12
  • @ChrisB there is no specific syntax required. Just the path for the jar file (not the directory), one per line. If you can't set the classpath, that is a separate issue. Without having the `OmniDriver.jar` file, it will be difficult for anyone to help you. – carandraug Jun 05 '15 at 17:39