Configuration:
- Developer Studio 5.3.1 / Linux
- WP77 R9 (18.3.0.wp77xx-native-x86_64-201806051023)
- Prepare your host
Follow this procedure:
https://source.sierrawireless.com/resources/airprime/software/legato_application_development_kit_linux/
especially the dedicated step:
If you plan to develop Legato applications with Java language
Then:
on host:
sudo get-install ant
- Retrieve the embedded JVM
for the test, I used ejdk-8u171-linux-arm-sflt.tar.gz
then
unzip to a local folder on your host PC, in my case in ~/ejdk/
- Create the app in dev studio:
In Projects perspective:
File > New > Import existing code as legato project
[Browse]
legato/packages/legato.framework.18.3.0.wp77xx-201806050955/resources/legato/apps/sample/javaHelloWorld/
check box: copy files into workspace
[Next]
Select your target platform, in my case [Built-in] Legato for WP77 R9
- Build you app
You have 2 options
- you can install the JVM on your target and point the app to it >> jump to section 5
- bundle the JVM in the app >> jump to section 6
- JVM on target
Advantage is application binary very small 3.6KB
Multiple java app can rely on the same JVM
5.1 install JVM on target
Copy the host folder ~/ejdk/ejdk1.8.0_171/linux_arm_sflt/compact1 content including subfolder /bin and /lib to the target file system
In my case in target folder /home/root/java
on target
cd ~
mkdir java
on host
cd ~/ejdk/ejdk1.8.0_171/linux_arm_sflt/compact1
scp -r ./* root@192.168.2.2:/home/root/java
5.2 configure the project
Right click on project > Properties > C/C++ Build > Environment > environment variables to set > [Add…]
Name: EJDK_DIR
Value: /home/root/java >> need to match the target folder defined in 4.1
Check: Add to all configurations
[OK]
[Apply and Close]
5.3 edit component.cdef
need to specify onTargetOracleJvm:
requires: { component: { onTargetOracleJvm }
5.4 Build and run
Click on the build and install icon (green arrow)
If everything went well, you should see the following target log message:
Jan 6 18:00:27 | UNKNOWN[21559]/javaHelloWorld T=main | io.legato.samples.javaHelloWorldComponent componentInit() 8 | Hello, World (from Java).
- Bundle the JVM in the app itself
Much bigger app since it also include the JVM. (12MB vs 3.6KB!)
Multiple java app will all have to embed their own JVM
Advantage: we are sure about which JVM version we run
6.1 configure the project
Right click on project > Properties > C/C++ Build > Environment > environment variables to set > [Add…]
Name: EJDK_DIR
Value: /home/bbo/ejdk/ejdk1.8.0_171/linux_arm_sflt/compact1 >> need to match the host location where you unzip the JVM
Check: Add to all configurations
[OK]
[Apply and Close]
6.2 edit component.cdef
need to specify embeddedOracleJvm
requires: { component: { embeddedOracleJvm }
6.3 Build and run
Click on the build and install icon (green arrow)
If everything went well, you should see the following target log message:
Jan 6 18:00:27 | UNKNOWN[21559]/javaHelloWorld T=main | io.legato.samples.javaHelloWorldComponent componentInit() 8 | Hello, World (from Java).