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
    May 17, 2013
    Daniel,

    I have a version of JRift which is now working on Mac OS X. I basically added a separate build system to your code which compiles the native library. Tested it with my Rift on a MacBook Pro with OS X 10.8.3, and the telemetry seems to come in correctly.

    If you're interested I'm willing to share my changes with you so you can integrate them with the official version.

    Just let me know.

    Kris
    Inspiring
    May 17, 2013
    Kris,

    great, can you make a pull request on github?
    Participant
    May 18, 2013
    OK, pull request sent. -- I hope; I'm pretty new to git and github. :-)
    38leinaDAuthor
    Up and Coming
    May 20, 2013
    thanks krisds for the mac os target, i have merged the pull request.
    once i have some time, i will provide a binary-version with windows and mac os native libs included. currently, you still have to build yourself.

    cheers,
    daniel
    Up and Coming
    June 20, 2013
    Hi all,
    I am a young Java fan developer.
    And a huge fan of Oculus ;) .

    I am trying to use the JRift Lib of 38leinaD.
    But I am stuck again. Could someone help me ?
    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:15)
    at de.fruitfly.ovr.OculusRift.main(OculusRift.java:92)


    Code uses/compiles on Window 8 (64 bit) with the OculusSDK 2.2 and Java JDK 1.7
    Someone has an idea on what is causing this exception and how to counter it ?
    Did someone already used JRift ?

    -------------------------------------------
    NB: I am like a young padawa without master.
    If someone want to guild me in the Java/Oculus world.
    I would be glad to meet him :P .
    Else the dark side (c++) will probably be my destiny :evil: .
    Up and Coming
    June 20, 2013
    "VgQD" wrote:
    ... Else the dark side (c++) will probably be my destiny :evil: .

    But the path to true enlightenment lies on the "dark side" (C++). Without darkness, there can be no light. Would Java even have evolved into being, if not for C/C++?
    :lol:
    Now, for TRUE knowledge, you need to learn x86/x64 assembler language, and pure WINAPI. That .NET nanny stuff is for children.
    ;)


    ... Actually, all languages have their place and time. You must use whatever makes you happy, and does not stand in your way.
    This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
    Up and Coming
    June 20, 2013
    "Be fear of the man who knows only one book"
    It is the same for programming languages. And I understand that ;).
    But one step at a time :D, I have until my death to learn other languages.

    Currently my problem is to learn how to use JRift correctly.
    And won't stop working on it until I success :twisted: .
    Up and Coming
    June 21, 2013
    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 !
    Up and Coming
    June 21, 2013
    "VgQD" wrote:
    ... Thanks to you Master. Your reply helped me in an indirect way.

    On the road again !

    So the "x86/x64" comment triggered an "Aha! moment" ("Eureka effect")? Glad you figured it out. ;)
    This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
    Up and Coming
    June 27, 2013
    Just to know :?:

    @38leinaD:
    In the JRift, , you did not implement the warped class for sensors
    and the JRift does not implement the setter of the Oculus SDK.

    Do you plan to code it ?

    (I would like to do it but ... :D
    )


    ----------------------------
    NB: Maybe someone has done it yet.
    But then I did not asked the good questions to my dear friend Google ;) .