Java on Omega with wrappers



  • I would like to use Java on the Omega
    It looks like this will be doable using JamVM (see http://jamvm.sourceforge.net/)
    There is a version of jamvm available from opkg, however when I do:
    opkg update
    opkg install jamvm
    I get the same kernel version error as in https://community.onion.io/topic/29/package-repo-sync-mismatch - i.e. kernel version on Omega is 3.18.21 but jamvm expects 3.18.20
    However, I note in the above referenced link that the Omega packages will be upgraded to the latest kernel version soon - so I can wait :-)

    However, I would like to know if there are or will be any Java wrappers for GPIO access, I2C access etc. If so any pointers or comments would be appreciated - thanks.

    Keep up the good work :-)



  • Hi Kit,

    If we can get Java VM to run on the Omega, that would be super cool! Have you had a chance to check out setting up a cross-compile environment for the Omega at https://github.com/OnionIoT/OpenWRT-Packages/wiki/Setting-Up-the-Cross-Compile-Environment. All we gotta do to solve this annoying kernel version issue is to recompile the package for the kernel that Omega is running on.

    Once we have the Java VM working, writing wrappers for it should be relatively simple.



  • Hi Boken, thanks for the info. Will let you know if/when I get anywhere with it :-)



  • Have been experimenting with building packages for Omega, with some success.

    In particular I would really like to run Java on the Omega and jamvm looks like it could be suitable.
    However, I still have not managed to resolve the kernel version mismatch though as in:

    opkg install jamvm
    ....
    Collected errors:
     satisfy_dependencies_for: Cannot satisfy the following dependencies for jamvm:
     kernel (= 3.18.20-1-7bed08fa9c06eb8089e82c200340ec66) *
     opkg_install_cmd: Cannot install package jamvm
    

    So I tried with opkg --force-depends install jamvm
    in the hope that it would work despite kernel version differences, but I got instead:

    Collected errors:
     satisfy_dependencies_for: Cannot satisfy the following dependencies for jamvm:
          kernel (= 3.18.20-1-7bed08fa9c06eb8089e82c200340ec66) *
     verify_pkg_installable: Only have 8548kb available on filesystem /overlay, pkg classpath needs 8786
     opkg_install_cmd: Cannot install package jamvm.
    

    The message:
    Only have 8548kb available on filesystem /overlay, pkg classpath needs 8786

    implies to me that the Omega does not have sufficient space to install jamvm :-(

    Am I correct?
    And is there anything I can do about it?

    A do have a 32GByte USB memory stick mounted on my Omega and can access it with no problem.
    Would it be possible to install jamvm to the USB and run it from there?

    How?



  • Hi @Kit-Bishop, currently we are still working on a bug in the OpenWRT system that bricks a device whenever you try to install opkg packages inside a USB drive. However, it seems like you just need a little bit more space to get jamvm installed. You might be able to compile jamvm directly into a firmware and flash the firmware into your device. Binaries that are compiled directly into the firmware tend to take up much less space than binaries that are installed via opkg.

    Please let me know if you are able to get it to work.

    Cheers.



  • @Boken-Lin Thanks :-)
    Currently working on Java wrappers for gpio access using JNI.
    Will keep you informed of progress.



  • In case anyone is interested, this is a brief report on my progress with Java on the Omega.
    What I have done so far:

    • Set up my Omega to have more space for /overlay directory on a USB drive using the pivot-overlay method described in https://wiki.onion.io/Tutorials/Using-USB-Storage-as-Rootfs
    • Installed jamvm using:
      • opkg update
      • opkg --force-depends install jamvm
        Note that --force-depends is needed to deal with kernel/repo version mismatches - it doesn't seem to cause any problems with this
    • Using NetBeans 8.1 (on my host KUbuntu system) created a small Java project and built it
    • Copied the resultant .jar file to my Omega
    • Ran the .jar file using:
      jamvm -jar <jar-file-name>

    It all ran exactly as hoped :-)

    I will now proceed with the following:



  • Nice. Interesting.



  • @Kit-Bishop have a look for http://pi4j.com
    It's java for raspberry pi, which deals with the GPIO stuff

    @Kit-Bishop said:

    • Write some Java classes that will access this GPIO JNI code to provide direct Java access to GPIO


  • @Joergi Thanks for the pointer. Looks interesting and does quite a bit more than I am currently aiming at. I really only need:

    1. Access to GPIO pins as input and output
    2. PWM output on GPIO pins
    3. Interrupt handling on GPIO pins
    4. I2C access

    I am currently close to having 1. and 2. done - 3. is still to be looked at and 4. will be a way off yet



  • There's some very interesting stuff that could be opened up with a JVM on the Omega. OpenHAB and Apache NiFi both spring to mind as cool IoT systems that could be fun.



  • Here's an update for the Omega2+. What I did to get the JVM on there was followed the instructions above to use pivot-overlay for a usb drive. Instead of the USB drive I used my SD Card in place. This worked perfectly.

    There are many packages that it couldn't find such as unzip and jamvm. After doing some research I added this line to my /etc/opkg/customfeeds.conf:

    src/gz lede_packages https://downloads.lede-project.org/releases/packages-17.01/mipsel_24kc/packages/

    Once I did that then I ran opkg update. From there I was able to install unzip and jamvm.



  • @Kit-Bishop You da man!


Log in to reply
 

Looks like your connection to Onion Community was lost, please wait while we try to reconnect.