Using rOmnidriver

Create issue
Issue #2 on hold
Nicholas Roberts created an issue

Dear Pedro

I’m really looking forward to using your library with our OO spectrometers.

After installing Omnidriver and then libraries (rJava, rOmniDriver), we always get the following error

w <- init_srs()
Error in .jnew("com/oceanoptics/omnidriver/api/wrapper/Wrapper") :

rJava seems to be working ok - e.g.

s <- .jnew('java.lang.Object')

works fine.

Any help appreciated

Comments (6)

  1. Pedro J. Aphalo repo owner

    Please, let me know what operating system and version you are using. If you get RJava to work then you must have installed the Java JDK. rOmniDriver has been working for me. I haven’t needed to update it for quite some time, but anyway, please tell me which version you are trying to use (I am using 0.1.13 with Omnidriver 2.56). Under Windows during installation of Omnidriver an environment variable is set in the operating system pointing to the folder where Omnidriver is installed. This is used by my package to find the library. Please, check if R can find it by typing at the R console:


    The statement above should display the path to the folder where Omnidriver is installed. (If the value is not correct you could try to set the environment variable to point to the correct folder.)

    What has caused earlier problems with OS X has been the handling by the package of the string with the path which may need different ways of escaping of special characters such as spaces under different operating systems. I have been testing the package only under Windows, and I am planning to start testing under Linux, but I do not have accsess to Apple computers.

    On my PC I get with no spectrometer connected.

    > w <- init_srs()
    > number_srs(w)
    Driver: NatUSBWin_64
    [1] 0
    > get_api_version(w)
    [1] "2.56"

    Please, do let me know any progress or lack of progress. I am very much interested in getting rOmniDriver debugged on as many OSs and hardware as possible.


  2. Nicholas Roberts reporter

    Thanks so much Pedro.

    Yes we are using OSX - 10.14.5.

    R version 3.5.3 (2019-03-11) -- "Great Truth"
    Platform: x86_64-apple-darwin15.6.0 (64-bit)

    Java 8 version 221

    When rOmniDriver loads

    OmniDriver initialization SUCCEEDED
    Path: /OmniDriver.jar


    [1] ""

    So yes the path to OI_HOME is not set - it is Macintosh HD⁩/⁨Applications⁩/⁨OmniDriverSPAM-2.56/OOI_HOME on this machine. ⁩

    When I set

    Sys.setenv(OI_HOME = "/Applications/OmniDriverSPAM-2.56/OOI_HOME")

    Then w <- init_srs() works fine.

    The next line then fails with an error of

    n <- number_srs(w)
    Error in .jcall("RJavaTools", "Ljava/lang/Object;", "invokeMethod", cl, : java.lang.NoClassDefFoundError: Could not initialize class com.oceanoptics.uniusb.UniUSB

    I’m still working on this one.

    Many thanks


  3. Pedro J. Aphalo repo owner

    This error is probably within the OmniDriver code itself, possibly not finding the USB driver. The function in my own package is coded as:

    open_all_spectrometers <- function(jwrapper){

    number_srs <- open_all_spectrometers # add shorter name!

    What is the OmniDriver version you are using?

  4. Nicholas Roberts reporter

    The omnidriver version is the latest from OOs website - OmniDriver+SPAM 2.56

    I’ve noticed in the OOI_HOME folder there is separate UniUSB.jar file - is that needed in addition to OmniDriver.jar? and related to the error of

    Could not initialize class com.oceanoptics.uniusb.UniUSB

    Many Thanks

  5. Pedro J. Aphalo repo owner


    In Windows an USB driver gets installed when one plugs-in an spectrometer for the same time. I think in Linux and possibly Unix or OS X you may need to change permissions to be able to write to an USB port or install the driver. You could first try logged in as root or start R using sudo. This is wild guessing as I only occasionally use Linux.

    Nowadays most of the documentation for OmniDriver is openly available at the OO website, there may be something useful in it.

    Best wishes,


  6. Pedro J. Aphalo repo owner

    Haven't heard from reporter if he could solve the problem or not. I have no access to OS X for testing myself.

  7. Log in to comment