NI Linux Real-Time Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Running java code on cRIO-9068

Hello,

I have an existing java code base that I would like to run on the cRIO-9068.  Assuming I am able to pull out any platform specific code, how would I go about executing this java code on the cRIO-9068?  Doing a `opkg update` and then `opkg list | grep java` did not produce what I would expect.  It appears that angstrum has the java6jdk, however that seems rather out of date.  Any chance NI will support this via opkg?

Thanks,

-TD

0 Kudos
Message 1 of 10
(6,760 Views)

Your best bet is to install the JDK on the 9068 based on the JDK download from Oracle. Oracle does not allow the JRE to be distributed as an opkg due to their licensing. You must get the latest from their website, thereby agreeing to their license.

Message 2 of 10
(4,880 Views)

I've had pretty good luck in the past using the openjdk package for a quick demo. It all depends on what you need from the preexisting software (and, of course, being aware that the default on NI Linux RT is a 256k stack, which prevents even a basic "Hello World" from running).

Of course, it would be handy if we actually provided a package that's installable, or even a way to build the package from our OE build tools (github.com/ni/nilrt). I'm working on some changes that can make that available and I'll test it out when I get a chance

0 Kudos
Message 3 of 10
(4,880 Views)

@DAQjr hmm, that may be true for Oracle's JDK, however openJDK is licensed under the GPLv2, so I don't see that being an issue.  Thank you for your insight though.

@BrandM if NI could provide an opkg installable binary package that would be *awesome*.  And if that isn't on the roadmap, then instructions on how to build it would be a good first step.

Additionally, with regard to the 256K stack, where abouts should I start looking to resolve that issue?

Thank you both for your responses.

0 Kudos
Message 4 of 10
(4,880 Views)

I spent a bit of time while I was traveling playing around with trying to add the meta-java layer to our OE build system (github.com/ni/nilrt) but it presented some non-trivial hurdles to get going. I'll play around with it a bit later.

As for the stack, there's a few ways to achieve that, depending on how you plan on launching the java code. Essentially, the distro is configured to launch every binary with a limited stack. You can either revert this (as I recall, there are two or three places where this happens) or specifically up the stack size from the console you'll be running your java from (if that is from LabVIEW RT, you may need to add the CAP_SYS_RESOURCE to /usr/local/natinst/labview/lvrt)

0 Kudos
Message 5 of 10
(4,880 Views)

If you are using the 2014 release the system wide value of the stack size is defined in /etc/default/rcS

e.g. # grep STACK /etc/default/rcS

STACK_SIZE=256

However it might be wiser to up it just for the processes that need it via 'ulimit -s' instead of system wide (like Brad mentioned above). LabVEW Real-Time avoids the latencies induced by pagging in memory by locking its working set in RAM so increasing the stack limit system wide will result in more memory being used, inacurate free memory reporting and possibly running out of physical memory.

It is usually safe to increase the stack size for other non-LabVIEW processes because it is all virtual memory paged in only when needed (i.e. they don't use mlockall to lock the virtual address space into RAM).

0 Kudos
Message 6 of 10
(4,880 Views)

I knew I was forgetting one place. At one point, there was actually two places that set it more or less globally and another specifically for LabVIEW.

Also, to get the behavior that gratian.crisan pointed out in the safest manner possible, you should probably write a quick wrapper binary that sets it's stack size larger (or unlimited) and use setcap to change the capabilities of the binary (our distro, like most, won't honor a capability set on a shell script). Call this binary from LabVIEW using the SystemExec VI. This sheds LVRT's stacks and memory-locking for your subprocess.

0 Kudos
Message 7 of 10
(4,880 Views)

I want to run a java code on the CRIO 9040, so I understand you need to install an ORACLE JDK on the CRIO 9040, would you like to know how I can install this JDK inside the CRIO?

0 Kudos
Message 8 of 10
(3,379 Views)

Hey smalhao,

 

I would recommend looking at the installation instructions on the openJDK website. You can find tarballs of the software. The caveats mentioned above in this thread still apply.

 

Thanks,

Andy

0 Kudos
Message 9 of 10
(3,361 Views)

Is there any example I can see how to install and run a java file directly on the compactRIO? I was looking at the openJDK website and is not explaining how it works in compactRIO

0 Kudos
Message 10 of 10
(3,348 Views)