Skip to main content
Up and Coming
April 5, 2013

Java Wrapper. First Version!

Hi There,
As a first note: I don't have my rift yet, so I have been writing this Java wrapper for the OR blindly. I would be cool if someone with a Rift and interest in Java could test it out:
https://dl.dropbox.com/u/8241387/OVR/JRift_alpha.zip

It is compiled for a 32-bit Java Runtime. And you can just call the contained JRift.bat to make it start a loop to read from the Rift sensors:

OculusRift or = new OculusRift();
or.init();

HMDInfo hmdInfo = or.getHMDInfo();
System.out.println(hmdInfo);

while (or.isInitialized()) {
or.poll();

System.out.println("Yaw: " + or.getYaw() + " Pitch: " + or.getPitch() + " Roll: " + or.getRoll());

try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
}

or.destroy();


Any comment is welcome.

Cheers,
Daniel

    43 replies

    Up and Coming
    August 26, 2013
    Man, Omg man !

    I want to buy you some beers :D
    Really, not for joking ;)

    I corrected the problems based on you reply.
    That was indeed the Visual Studio debug mode.
    Currently uploading a running build on the VRJAM :P
    New Participant
    September 13, 2013
    That's gonna be fairly useful.
    New Participant
    December 15, 2013
    I'm trying to use the wrapper but when I try to run the main from OculusRift.java I'm always getting this error:

    Exception in thread "main" java.lang.UnsatisfiedLinkError: C:\xxx\xxx\JRiftLibrary.dll: Invalid access to memory location
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary1(Unknown Source)
    at java.lang.ClassLoader.loadLibrary0(Unknown Source)
    at java.lang.ClassLoader.loadLibrary(Unknown Source)
    at java.lang.Runtime.loadLibrary0(Unknown Source)
    at java.lang.System.loadLibrary(Unknown Source)
    at de.fruitfly.ovr.OculusRift.<clinit>(OculusRift.java:87)


    I compiled libovr and JRiftLibrary using MSVC2012 as 64-bit multithreaded DLL. My Java-version is also 64-bit. Does anyone have a clue why this isn't working?

    Cheers,
    Marius
    New Participant
    December 19, 2013
    It worked with mabrowning's version of JRift, but I can't say why: https://github.com/mabrowning/JRift
    Up and Coming
    January 18, 2014
    I see the mabrowning native binaries are 5 month old, are there any newer builds somewhere?
    "It's like Homeworld in first person." Disable Aero and vSync for a completely simulator sickness free experience with 2xHz FPS. Keep the config utility open for tracking to work.
    Participant
    February 6, 2014
    What else do you need in them? The latest builds should be the latest SDK. Look here for the actual latest builds: https://github.com/mabrowning/minecrift-repo/tree/gh-pages/de/fruitfly/ovr

    JRiftLibrary/*-natives-[windows|osx|linux].jar has the native libs
    JRift has the java code.
    Up and Coming
    February 7, 2014
    "mabrowning" wrote:
    What else do you need in them? The latest builds should be the latest SDK. Look here for the actual latest builds: https://github.com/mabrowning/minecrift-repo/tree/gh-pages/de/fruitfly/ovr

    JRiftLibrary/*-natives-[windows|osx|linux].jar has the native libs
    JRift has the java code.


    32/64 bits?
    Up and Coming
    February 13, 2014
    So, I am trying to run a simple example

    public class Test {

    public static void main(String args[]) {

    OculusRift oculusRift = new OculusRift();
    oculusRift.init();

    HMDInfo hdmInfo = oculusRift.getHMDInfo();
    System.out.println(hdmInfo);

    // while(oculusRift.isInitialized()){
    //
    // }

    oculusRift.destroy();
    }
    }


    But I get this error

    Exception in thread "main" java.lang.UnsatisfiedLinkError: de.fruitfly.ovr.OculusRift._initSubsystem()Z
    at de.fruitfly.ovr.OculusRift._initSubsystem(Native Method)
    at de.fruitfly.ovr.OculusRift.init(OculusRift.java:82)
    at ec.test.test3.Test.main(Test.java:21)
    Java Result: 1


    I created and included a Library based on:
    - JRift-0.2.5.1.jar
    - JRiftLibrary-0.2.5.1.jar
    - JRiftLibrary-0.2.5.1-natives-windows.jar

    What is missing?
    Up and Coming
    February 13, 2014
    Investingating more on the error it seems that
    something is wrong with the library itself in the sense that Java is not able to map a native Java function in your application to its actual native counterpart.


    I extracted both library and forced the loading,

    System.loadLibrary("JRiftLibrary64");

    And now it works

    Where I am doing wrong?
    Up and Coming
    April 14, 2014
    Hi everyone,
    I'm 19, 2y-IT student and i'm currently in a working experience at the Spatial Database Center (CDS) of Strasbourg. I have to make a software prototype with the Oculus with Java.
    I've decided to use jMonkeyEngine just to try to modelize planets, and being able just to watch them.
    I'll be very glad if somebody would be able to explain me how can I generate the screen which is necessary to the Oculus if you want to get VR, i'm talking about this screen with the double view with the shift between these two images: http://img0.gm.gtsstatic.com/wallpapers/c2a626926b723c816ebcafafc3d05c2c_large.jpeg
    I've never done 3D until this experience and I'm not really good at, but I managed to modelize a planet, and know, before implements motion functions, i'd like to visualize it in VR with the Oculus.
    Of anybody could help, it will be very pleasant :)
    Thank you all, and sorry for my bad english x)
    - Joffrey (no jokes about GoT pls :cry: !)
    ~ Don't forget: What you want, will be.