How to import a package from a jar

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/

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

Thanks

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

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

Richard

Try this:

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

Richard

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).

Thanks, it’s working.

But now i have a java question.

I’m testing this little code :

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

I found the problem, i need to use

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