# How to import a package from a jar

**URL:** <https://community.wowza.com/t/how-to-import-a-package-from-a-jar/583>\
**Category:** Wowza Developer Dojo\
**Tags:** wowza-streaming-server-java-api\
**Created:** [October 9, 2012, 10:38am UTC](https://community.wowza.com/t/how-to-import-a-package-from-a-jar/583 "2012-10-09T10:38:10Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/flex002/user_avatar/community.wowza.com/system/32/447_2.png) [@system](https://community.wowza.com/u/system)\
**Post date:** [October 9, 2012, 10:38am UTC](https://community.wowza.com/t/how-to-import-a-package-from-a-jar/583/1 "2012-10-09T10:38:10Z")

</div>

Hello,

I’m sorry for my basic question but i don’t know well java and Wowza IDE based on Eclipse.

So, i would like to import a package “org.apache.commons.codec.binary.Base64”

from [http://commons.apache.org/codec/](http://commons.apache.org/codec/)

but how to tell to my script where is the jar ?

Thanks

---

<div class="post-metadata">

**Author:** ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)\
**Post date:** [October 9, 2012, 11:40am UTC](https://community.wowza.com/t/how-to-import-a-package-from-a-jar/583/2 "2012-10-09T11:40:24Z")

</div>

You just copy the .jar file to Wowza /lib folder. If the IDE is setup right there is nothing else to do except write the import and start Wowza

Richard

---

<div class="post-metadata">

**Author:** ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)\
**Post date:** [October 9, 2012, 12:20pm UTC](https://community.wowza.com/t/how-to-import-a-package-from-a-jar/583/3 "2012-10-09T12:20:41Z")

</div>

IDE: Project \> Properties \> Libraries (tab) \> Add External Jars (button) \> navigate to the new .jar in the /lib folder.

Richard

---

<div class="post-metadata">

**Author:** ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)\
**Post date:** [October 9, 2012, 12:58pm UTC](https://community.wowza.com/t/how-to-import-a-package-from-a-jar/583/4 "2012-10-09T12:58:50Z")

</div>

Try this:

```auto
String base64DataStr = Base64.encodeBytes(byteArrayData, Base64.DONT_BREAK_LINES);

```

Richard

---

<div class="post-metadata">

**Author:** ![Julien\_Jabouin](https://avatars.discourse-cdn.com/v4/letter/j/7ba0ec/32.png) [@Julien\_Jabouin](https://community.wowza.com/u/Julien_Jabouin)\
**Post date:** [October 9, 2012, 12:52pm UTC](https://community.wowza.com/t/how-to-import-a-package-from-a-jar/583/5 "2012-10-09T12:52:04Z")

</div>

I copied “commons-codec-1.7.jar” in /Library/WowzaMediaServer-3.1.2/lib/

but when i put this line in my code :

import org.apache.commons.codec.binary.Base64;

I obtain “The import org.apache.commons.codec cannot be resolved” (where “org.apache.commons.codec.binary.Base64” is underlined).

---

<div class="post-metadata">

**Author:** ![Julien\_Jabouin](https://avatars.discourse-cdn.com/v4/letter/j/7ba0ec/32.png) [@Julien\_Jabouin](https://community.wowza.com/u/Julien_Jabouin)\
**Post date:** [October 9, 2012, 1:50pm UTC](https://community.wowza.com/t/how-to-import-a-package-from-a-jar/583/6 "2012-10-09T13:50:38Z")

</div>

Thanks, it’s working.

But now i have a java question.

I’m testing this little code :

```auto
byte[] encodedBytes = Base64.encodeBase64("192.168.0.1:186:6524395".getBytes());
getLogger().info("encodedBytes : "+encodedBytes.toString());
byte[] decodedBytes = Base64.decodeBase64(encodedBytes);
getLogger().info("decodedBytes : "+decodedBytes.toString());

```

And the result is :

INFO server comment - encodedBytes : [B@58f71157

INFO server comment - decodedBytes : [B@44939462

Do you know why ?

Normally i need to obtain “MTkyLjE2OC4wLjE6MTg2OjY1MjQzOTU=” for encoded string and “192.168.0.1:186:6524395” for decoding string.

So it’s juste for testing because i will send the base64 encoded string by query string, i just need to decode it in the java module.

Thanks

---

<div class="post-metadata">

**Author:** ![Julien\_Jabouin](https://avatars.discourse-cdn.com/v4/letter/j/7ba0ec/32.png) [@Julien\_Jabouin](https://community.wowza.com/u/Julien_Jabouin)\
**Post date:** [October 9, 2012, 2:19pm UTC](https://community.wowza.com/t/how-to-import-a-package-from-a-jar/583/7 "2012-10-09T14:19:54Z")

</div>

I found the problem, i need to use

new String(encodedBytes) in place of encodedBytes.toString()
