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

    Participant
    June 29, 2013
    "VgQD" wrote:
    MOUaahahah :P
    I resolved my problems... my noob problems ^^

    So for this exception:
    - Exception in thread "main" java.lang.UnsatisfiedLinkError: C:\VgQD\Save\Oculus\workspace\OculusFirstApp\JRiftLibrary.dll: Can't load IA 32-bit .dll on a AMD 64-bit platform
    It was because my JDK was a 64 bit. I through that the exception spoke about my OS :roll:

    - Exception in thread "main" java.lang.UnsatisfiedLinkError: de.fruitfly.ovr.OculusRift.initSubsystem()Z
    It was a miss-understanding, I had to include jdk/inlude/win32 in the c/c++ dependance at the compilation too.
    And the compilation did not fail cause I forget a file :lol: .

    Thanks to you Master. Your reply helped me in an indirect way.

    On the road again !



    :) you just beat me to it. I was reading your post, and directly thought this might be a 64 bit issue as you prop need 32bit jdk.

    Im currently coding in c# but i learn programming in java, and there pretty alike.

    Its always nice to find the issue :).

    Goodluck
    Participant
    June 29, 2013
    "MrGeddings" wrote:
    Nice now this will pave the way for making Minecraft work with the Rift! wow thatd be awesome if by the time i get the Rift someone would have it working :-D wheee! Minecraft really is one of my favorite games as how open and creative it can be and how fun it is just exploring other servers online :-).



    Minecraft is a pretty fun game indeed.

    I gues you know, but there is a mod allready out that gives minecraft support for the oculus rift. You have to use
    A custom laucher that implement OR support. It add vr options for the OR.

    I have Played it, and its pretty ok.


    Cheers
    Participant
    July 4, 2013
    Hi Daniel,

    Any news on getting the wrapper up and running with the new sdk? I got my oculus today and will look into using the wrapper in the weekend. :)

    Mike
    Game in pre-alpha with support for Oculus Rift DK2 coming in the next patch, State of Fortune
    Inspiring
    August 16, 2013
    Feel free to extend the existing Java code at the community SDK as a starting point. It's not actually a wrapper for the OVR code, but rather a Java re-implementation of the core functionality. Right now it only includes the head tracking component, without sensor fusion or HMD locating / reporting, but I'd like to get it extended to cover the core functionality of the C++ SDK.
    Brad Davis - Developer for High Fidelity Co-author of Oculus Rift in Action
    Participant
    August 17, 2013
    Don't mean to hijack the thread (but i guess i just did).
    I've implemented rift support for jmonkeyengine. The code is posted here: http://code.google.com/p/jmonkeyengine-oculus-rift/
    If you're only looking for wrappers, you can download oculuslib.jar. It contains natives for 32 and 64 bit windows + ovrlib for 0.2.3
    For usage, check out OculusRift.java and OculusRiftReader.java

    Edit: Wow, simultaneous posting in a java thread.
    "The television screen has become the retina of the minds eye."
    Up and Coming
    August 24, 2013
    Please help me :cry:
    I am totally lost. And I have 24 h to fix this.

    I am participating to the VRJam.
    https://github.com/VgQD/ChogathFanGame
    My game work well and is in JavaFX 2.0 for window.

    I use the JRift of 38leinaD.
    Every thing is fine except that when I try to run my Jar on others computers, I have go this error:

    Caused by: java.lang.UnsatisfiedLinkError: C:\Users\Eloi\Desktop\Oculus\workspace\ChoGath\JRiftLibrary.dll: Can't find dependent libraries


    Any idea of what I should do to resolve this issue ?


    Exception in Application start method
    Exception in thread "main" java.lang.RuntimeException: Exception in Application start method
    at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:403)
    at com.sun.javafx.application.LauncherImpl.access$000(LauncherImpl.java:47)
    at com.sun.javafx.application.LauncherImpl$1.run(LauncherImpl.java:115)
    at java.lang.Thread.run(Unknown Source)
    Caused by: java.lang.UnsatisfiedLinkError: C:\Users\Eloi\Desktop\Oculus\workspace\ChoGath\JRiftLibrary.dll: Can't find dependent libraries
    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)
    at be.vgqd.vrjam.game.chogath.oculus.OculusControllerData.<clinit>(OculusControllerData.java:11)
    at be.vgqd.vrjam.game.chogath.contract.impl.X360OculusMode1.<init>(X360OculusMode1.java:43)
    at be.vgqd.vrjam.game.chogath.contract.impl.Modes.getContactMode1(Modes.java:8)
    at be.vgqd.vrjam.game.chogath.Game.init(Game.java:46)
    at be.vgqd.vrjam.game.chogath.Game.<init>(Game.java:41)
    at be.vgqd.vrjam.game.chogath.Game.createInstance(Game.java:31)
    at be.vgqd.vrjam.game.chogath.Launcher.start(Launcher.java:38)
    at com.sun.javafx.application.LauncherImpl$5.run(LauncherImpl.java:319)
    at com.sun.javafx.application.PlatformImpl$5.run(PlatformImpl.java:215)
    at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:179)
    at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:176)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.application.PlatformImpl$4.run(PlatformImpl.java:176)
    at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at com.sun.glass.ui.win.WinApplication.access$100(WinApplication.java:29)
    at com.sun.glass.ui.win.WinApplication$3$1.run(WinApplication.java:73)
    ... 1 more
    Inspiring
    August 25, 2013
    The stack trace makes it look like the JRiftLibrary.dll is looking for a DLL that isn't there. You should examine the DLL located at the path in the stack trace with a tool meant to find out what's missing, like this: http://www.dependencywalker.com/

    It's also possible I'm misinterpreting the error and it means that the JRiftLibrary itself is missing and that's just one of the locations it's looking for it int. In that case you need to get that DLL and put it on your path.
    Brad Davis - Developer for High Fidelity Co-author of Oculus Rift in Action
    Up and Coming
    August 25, 2013
    I did it and there are 3 files not found:
    MSVCP110D.DLL
    MSVCR110D.DLL
    IESHIMS.DLL

    I try to found them on an other computer and to copied them to the same folders.
    But it did nothing more.
    Am I doing it wrong :| ?

    Tomorrow, I am going to try build the JRiftLibrary.DLL by myself.
    I do not know if it will change something. But it is my last hope :( .
    Up and Coming
    August 25, 2013
    24 day of coding for finish on a good game but I am the only one that can play to it -_-.
    I will commit it but it is pointless.

    This is in this kind of situation that I just want to stop being software developer and work in a Mc Do :cry:
    Inspiring
    August 25, 2013
    "VgQD" wrote:
    MSVCR110D.DLL


    That's the Visual C runtime DLL. That D on the end means that's the debug version. The only people who are going to have that on their system are people who have Visual Studio 2012 installed. Dependong on how you got your JRiftLibrary.dll you may need to search for a corresponding non-Debug one. If you're compiling it yourself, you need to switch to the Release configuration in Visual Studio and / or go into the project properties and set the code generation to use the non-debug versions of the C runtime, i.e. 'multi-threaded' instead of 'multi-threaded debug'. Part of that setting also lets you choose between DLL and static libraries. If you choose static libraries, the whole problem goes away because it won't be relying on an external DLL for the runtime.

    "VgQD" wrote:
    24 day of coding for finish on a good game but I am the only one that can play to it -_-.
    I will commit it but it is pointless.


    If the above doesn't work and you can try using my Java bindings in my GitHub repo:
    https://github.com/jherico/OculusSDK/tree/unstable/Bindings/Java

    They're only usable for reading the Rift's head tracker and accessing the HID information, but depending on how you're initializing the rendering context and identifying the Rift output, that might be enough.
    Brad Davis - Developer for High Fidelity Co-author of Oculus Rift in Action