MangOH Red java

Hello

Is the MangOH red can run java program ?
In legato v16.10, we have a small documentation how to install it ( https://docs.legato.io/16_10/javaBuild.html)

But, in legato v20, can we install a jdk to run java program ? ( and how do it ? )

Thank’s

Does this help?

Hello

Thank for this tutorial, but in legato 20, it seem that java was disable.
Currently, the developer studio is out, so for define de EJDK parameter , i use this command:

leaf env profile --set EJDK_DIR=/home/root/java

but when i try to make application javaHelloWorld with the command mkapp:

> mkapp apps/javaHelloWorld.adef -s components -t ${LEGATO_TARGET}
** WARNING: 
/opt/mongo/components/javaHelloWorldComponent/Component.cdef:1:0: warning: Java package added, but LE_CONFIG_ENABLE_JAVA is not set.  Are the KConfig values correctly configured?
** ERROR:
/opt/mongo/components/javaHelloWorldComponent/Component.cdef:11:8: error: Couldn't find component 'onTargetOracleJvm'.

The LE_CONFIG_ENABLE_JAVA seems to be a parameter in legato build procedure:

~/.leaf/wp77-legato_20.04.0-202004151904$ find . -type f -exec grep LE_CONFIG_ENABLE_JAVA {} \; -print
        !envVars::GetConfigBool("LE_CONFIG_ENABLE_JAVA"))
            LE_I18N("Java package added, but LE_CONFIG_ENABLE_JAVA is not set.  Are the KConfig "
./framework/tools/defTools/modeller/componentModeller.cpp

I’m not sure to be able to recompile legato.

I tried in Developer studio + WP77 R9.1 with legato 18.6.1 and WP77 R11 with legato 18.9.2, both of them can compile the javaHelloWorld.
You can give a try on that.

Ok, i’ve downgrade my configuration to WP77 R9.1 ( i’ve downgrade mangOH because last version won’t compile with R9.1 )

The java runtime work perfectly.
I import a simple HelloWorld.class and the mangOH run it.

But the application javaHelloWorld search legatojni and crash. (the legato.jar and liblegatoJni.so are present)

Aug 12 15:32:08 swi-mdm9x28-wp user.info Legato:  INFO | supervisor[882]/supervisor T=main | app.c CreateFileLink() 2085 | Skipping file link '/legato/systems/current/lib/legato.jar' to '/legato/systems/current/appsWriteable/javaHelloWorld/lib/legato.jar': Already exists
Aug 12 15:32:08 swi-mdm9x28-wp user.info Legato:  INFO | supervisor[882]/supervisor T=main | app.c CreateFileLink() 2085 | Skipping file link '/legato/systems/current/lib/liblegatoJni.so' to '/legato/systems/current/appsWriteable/javaHelloWorld/lib/liblegatoJni.so': Already e
Aug 12 15:32:08 swi-mdm9x28-wp user.info Legato:  INFO | supervisor[882]/supervisor T=main | resourceLimits.c GetCfgResourceLimit() 207 | Configured resource limit maxStackBytes is not available.  Using the default value 0.
Aug 12 15:32:08 swi-mdm9x28-wp user.info Legato:  INFO | supervisor[882]/supervisor T=main | proc.c proc_Start() 1403 | Starting process 'helloJava' with pid 10818
Aug 12 15:32:08 swi-mdm9x28-wp user.info Legato:  INFO | supervisor[882]/supervisor T=main | supervisor.c SigChildHandler() 874 | Reaping unconfigured child process 10814.
Aug 12 15:32:08 swi-mdm9x28-wp user.info Legato:  INFO | supervisor[10818]/supervisor T=main | proc.c proc_Start() 1363 | Execing 'java'
Aug 12 15:32:08 swi-mdm9x28-wp user.err Legato: =ERR= | helloJava[10818] | java.lang.UnsatisfiedLinkError: no legatoJni in java.library.path
Aug 12 15:32:08 swi-mdm9x28-wp user.err Legato: =ERR= | helloJava[10818] | 
Aug 12 15:32:08 swi-mdm9x28-wp user.err Legato: =ERR= | helloJava[10818] | 	at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1867)
Aug 12 15:32:08 swi-mdm9x28-wp user.err Legato: =ERR= | helloJava[10818] | 
Aug 12 15:32:08 swi-mdm9x28-wp user.err Legato: =ERR= | helloJava[10818] | 	at java.lang.Runtime.loadLibrary0(Runtime.java:870)
Aug 12 15:32:08 swi-mdm9x28-wp user.err Legato: =ERR= | helloJava[10818] | 
Aug 12 15:32:08 swi-mdm9x28-wp user.err Legato: =ERR= | helloJava[10818] | 	at java.lang.System.loadLibrary(System.java:1122)
Aug 12 15:32:08 swi-mdm9x28-wp user.err Legato: =ERR= | helloJava[10818] | 
Aug 12 15:32:08 swi-mdm9x28-wp user.err Legato: =ERR= | helloJava[10818] | 	at io.legato.LegatoJni.<clinit>(LegatoJni.java:26)
Aug 12 15:32:08 swi-mdm9x28-wp user.err Legato: =ERR= | helloJava[10818] | 
Aug 12 15:32:08 swi-mdm9x28-wp user.err Legato: =ERR= | helloJava[10818] | 	at io.legato.LogHandler.<init>(LogHandler.java:49)
Aug 12 15:32:08 swi-mdm9x28-wp user.err Legato: =ERR= | helloJava[10818] | 
Aug 12 15:32:08 swi-mdm9x28-wp user.err Legato: =ERR= | helloJava[10818] | 	at io.legato.generated.exe.helloJava.Main.main(Main.java:25)

For the moment , java run but not legato java application.

For purpose, if you haven’t Developer studio , you must :

  1. run leaf env profile --set EJDK_DIR=/home/root/java
  2. add the -s ${LEGATO_ROOT}/components to be able to genarate application with mkapp or mksys

I remember I tried in WP76 FW R9, I can see “Hello, World (from Java)” inb the log message.