# External Java libraries

**URL:** <https://forum.legato.io/t/external-java-libraries/2416>\
**Category:** Legato Linux distribution (Yocto project)\
**Created:** [April 12, 2017, 9:50pm UTC](https://forum.legato.io/t/external-java-libraries/2416 "2017-04-12T21:50:12Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![tli](https://avatars.discourse-cdn.com/v4/letter/t/50afbb/32.png) [@tli](https://forum.legato.io/u/tli)\
**Post date:** [April 12, 2017, 9:50pm UTC](https://forum.legato.io/t/external-java-libraries/2416/1 "2017-04-12T21:50:12Z")

</div>

Hi,  
I am trying to use external Java libraries for a mangOH green in my Legato Java application. I use Developer Studio 5.0 and the “JavaHelloWorld” sample works fine. I added the libraries I want to use in the project properties under “Java Build Path”. Also I include them at the “Component.cdef” file with “bundles: {file: { … } } “. But every time I get the error: “package does not exist”.

---

<div class="post-metadata">

**Author:** ![daav](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/daav/32/64_2.png) [@daav](https://forum.legato.io/u/daav)\
**Post date:** [April 13, 2017, 8:57am UTC](https://forum.legato.io/t/external-java-libraries/2416/2 "2017-04-13T08:57:22Z")

</div>

Hi @tli

This is a known limitation.  
You’re doing the things the right way, but for now the class path used at compilation time and at runtime doesn’t take bundled jar files into account.  
We’re starting a rework task concerning Java for Legato here, and this will be fixed in next major Legato release (should be released at some time in June 2017)

---

<div class="post-metadata">

**Author:** ![kent1ukr](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/kent1ukr/32/255_2.png) [@kent1ukr](https://forum.legato.io/u/kent1ukr)\
**Post date:** [October 31, 2017, 4:00pm UTC](https://forum.legato.io/t/external-java-libraries/2416/3 "2017-10-31T16:00:11Z")

</div>

Hi, @daav!  
I’m very intrested in using java with external libraries on my mangoh + wp8548 module, but it seems that there was no update of legato AF since that theme was started.  
Is that true, or i can install anything newer than 16.10.3 ([source](https://source.sierrawireless.com/resources/airprime/software/legato_application_development_kit_linux/))  
Regards!

---

<div class="post-metadata">

**Author:** ![daav](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/daav/32/64_2.png) [@daav](https://forum.legato.io/u/daav)\
**Post date:** [November 2, 2017, 9:00am UTC](https://forum.legato.io/t/external-java-libraries/2416/4 "2017-11-02T09:00:34Z")

</div>

Hi @kent1ukr

Java updates have been implemented among successive versions since 16.10.3, but it’s true that this one it still the latest official package for WP85 (please refer to [http://legato.io/legato-docs/latest/aboutReleaseInfo.html](http://legato.io/legato-docs/latest/aboutReleaseInfo.html) for more information on how hardware package releases are scheduled WRT. the master monthly releases)

That said, you still can build the Framework by your own, at the version you want, and get it into DS so that you can build apps on top of it (Instructions here: [Adding newest version Legato Framework into Developer Studio](http://forum.legato.io/t/adding-newest-version-legato-framework-into-developer-studio/2654))

---

<div class="post-metadata">

**Author:** ![kent1ukr](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/kent1ukr/32/255_2.png) [@kent1ukr](https://forum.legato.io/u/kent1ukr)\
**Post date:** [November 3, 2017, 11:26am UTC](https://forum.legato.io/t/external-java-libraries/2416/5 "2017-11-03T11:26:40Z")

</div>

Hi again @daav  
I have recently tryed to build LF by my own, but i have an issue  
First of all I followed an instruction [here]([GitHub - legatoproject/legato-af: Legato Application Framework](https://github.com/legatoproject/legato-af) Install required packages)  
I downloaded and installed latest toolchain 64-bit SWI9X15Y\_07.12.09.00 on WP85  
Cloned repo legato-af from GitHub  
Compiled make and make wp85. Got compiled folder …/legato/build/wp85  
Added in developer studio compiled framework according to [instruction](http://forum.legato.io/t/adding-newest-version-legato-framework-into-developer-studio/2654/2)  
Regards!

And now after creating new Legato Application I have no legato.jar and get en exception “SPN\_HOME…/legato/build/wp85/framework/lib/legato.jar (missing).”  
And I have onli ‘.so’ files in my lib folder.

I just can’t realize what am I doing wrong. Please help me if you have any suggestions

---

<div class="post-metadata">

**Author:** ![daav](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/daav/32/64_2.png) [@daav](https://forum.legato.io/u/daav)\
**Post date:** [November 3, 2017, 12:17pm UTC](https://forum.legato.io/t/external-java-libraries/2416/6 "2017-11-03T12:17:36Z")

</div>

Hi @kent1ukr,  
I’m afraid this is not documented anywhere, but in order to get Java support built when you’re building your own Framework, you need:

- to be sure that you have a JDK installed on your machine (check that **javac** command is running OK; minimum version: Java 8)
- to set the following env var ~~s~~ **before** building the framework ( **make wp85** ):  
~~**export JAVA\_INCLUDE\_DIR=/usr/lib/jvm/java-8-openjdk-amd64/**~~  
**export JDK\_INCLUDE\_DIR=/usr/lib/jvm/java-8-openjdk-amd64/include**

Then, you should get the legato.jar built.

---

<div class="post-metadata">

**Author:** ![kent1ukr](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/kent1ukr/32/255_2.png) [@kent1ukr](https://forum.legato.io/u/kent1ukr)\
**Post date:** [November 3, 2017, 2:30pm UTC](https://forum.legato.io/t/external-java-libraries/2416/7 "2017-11-03T14:30:20Z")

</div>

@daav, I have just did what you wrote.  
I do have JDK  
I exported both passes  
but it’s still soesn’t compile LF for me ☹  
Can it be because off I don’t use latest toolchain (latest available toolchain for me according [this page](https://source.sierrawireless.com/resources/legato/downloads/) is SWI9X15Y\_07.12.09.00 )  
thanks for your quick responces

---

<div class="post-metadata">

**Author:** ![daav](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/daav/32/64_2.png) [@daav](https://forum.legato.io/u/daav)\
**Post date:** [November 3, 2017, 2:49pm UTC](https://forum.legato.io/t/external-java-libraries/2416/8 "2017-11-03T14:49:51Z")

</div>

Did you verify if legato.jar is built on the file system after a **make wp85**?  
Maybe you need to do a **make clean** before trying a new build…

That said, please note that on DS side, you’ll probably need to import again the package (from the _Available Packages_ view), because some metadata are cached at this time (notably if the framework provides a legato.jar or not…)

---

<div class="post-metadata">

**Author:** ![kent1ukr](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/kent1ukr/32/255_2.png) [@kent1ukr](https://forum.legato.io/u/kent1ukr)\
**Post date:** [November 3, 2017, 3:20pm UTC](https://forum.legato.io/t/external-java-libraries/2416/9 "2017-11-03T15:20:53Z")

</div>

@daav I tryed too do a **make claen** and i have eve tryed too delete old wp85 folder before making **make85** but it still did not helped at all… I still don’t have .jar file in my lib folder

---

<div class="post-metadata">

**Author:** ![daav](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/daav/32/64_2.png) [@daav](https://forum.legato.io/u/daav)\
**Post date:** [November 3, 2017, 3:38pm UTC](https://forum.legato.io/t/external-java-libraries/2416/10 "2017-11-03T15:38:02Z")

</div>

Please note that the export settings above must be:

- either done manually each time you open a new shell
- or added to your **.bashrc** profile

If you do a **ls $JDK\_INCLUDE\_DIR** before the Legato build, is it showing up the content of **/usr/lib/jvm/java-8-openjdk-amd64/include**?

EDIT: only JDK\_INCLUDE\_DIR var is mandatory (I edited my previous post).  
Just gave a try on a fresh 17.09 repo clone.

```
$ export JDK_INCLUDE_DIR=/usr/lib/jvm/java-8-openjdk-amd64/include
$ ls $JDK_INCLUDE_DIR 
classfile_constants.h jawt.h jdwpTransport.h jni.h jvmticmlr.h jvmti.h linux
$ make
<snipped output>
$ . bin/configlegatoenv
$ make wp85
<snipped output>
$ find -name *.jar
./3rdParty/pjsip/pjsip-apps/src/pjsua/android/gradle/wrapper/gradle-wrapper.jar
./3rdParty/pjsip/pjsip-apps/src/swig/java/android/gradle/wrapper/gradle-wrapper.jar
./3rdParty/Lwm2mCore/doc/plantuml/plantuml.jar
./3rdParty/plantuml/plantuml.jar
./3rdParty/plantuml/plantuml-8049.jar
./build/wp85/system/staging/lib/legato.jar
./build/wp85/framework/lib/legato.jar
./build/wp85/_staging_system.wp85.update/system/lib/legato.jar
./build/localhost/system/staging/lib/legato.jar
./build/localhost/framework/lib/legato.jar

```

---

<div class="post-metadata">

**Author:** ![kent1ukr](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/kent1ukr/32/255_2.png) [@kent1ukr](https://forum.legato.io/u/kent1ukr)\
**Post date:** [November 8, 2017, 12:10pm UTC](https://forum.legato.io/t/external-java-libraries/2416/11 "2017-11-08T12:10:59Z")

</div>

> [@daav](#):
>
> either done manually each time you open a new shell

That was the main thing in my case. Thanks a lot about that!!!

Despite this I still can’t configure my project properly to use external java libraries.  
I added extrnal library like I used to do it in eclipse ([like here](http://www.oxfordmathcenter.com/drupal7/node/44)) but when I try to build my project it still doesn’t see that library ( package does not exist ).  
So it seems that I’m still there were I started a week ago, but now I have 17.09.0 LF in DS.  
Thanks again for your answers.

---

<div class="post-metadata">

**Author:** ![bren](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/bren/32/259_2.png) [@bren](https://forum.legato.io/u/bren)\
**Post date:** [December 18, 2017, 7:20pm UTC](https://forum.legato.io/t/external-java-libraries/2416/12 "2017-12-18T19:20:01Z")

</div>

Hi @daav.  
I also have issues with using external jar on my Legato java project.  
I’m using mangOH Green with wp8548. According to your recommendations, I updated framework to version 17.09.0 and added it to the DS. Despite this, I also get errors( package does not exist ).  
Could you please explain how to properly add and use external jars. In the official documentation (`http://legato.io/legato-docs`), I did not find any instructions on this case.  
Thanks for the answer.

---

<div class="post-metadata">

**Author:** ![daav](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/daav/32/64_2.png) [@daav](https://forum.legato.io/u/daav)\
**Post date:** [December 19, 2017, 6:39am UTC](https://forum.legato.io/t/external-java-libraries/2416/13 "2017-12-19T06:39:39Z")

</div>

Hi,

unfortunately there is no workaround at the moment.  
But yes, this is a blocking point… We’re currently investigating on how we could get this fixed in a future version.
