# java packages

Helma puts the whole wealth of Java libraries at your fingertips. The "Packages" object in Helma's Javascript environment serves as the doorway to leverage any Java packages in the CLASSPATH. You can add any Java packages to the CLASSPATH simply by putting the jar files in the ./lib/ext/ directory.

Any public methods that these Java classes define become callable from your application's Javascript environment and you can create and work with Java objects just like you do with Javascript objects. For example, you could create a Java StringBuffer object and then append data to it as follows:

    var buffer = new Packages.java.lang.StringBuffer();
    buffer.append('hello');

If your application makes extensive use of a Java class, it might be a good idea to wrap that class in a Javascript prototype. That way, the objects your applications works with become true Javascript objects, you can control exactly which class methods are exposed to your application and you can abstract the implementation, allowing you to change the Java classes you use without requiring modifications to your application.

Various examples of such wrappers around Java classes can be found in the helmaLib, which makes Mail, File, Ftp, Image, Search, SSH and Zip functionality available in this way.

More information on how Helma makes Java scriptable:
/rhino/ScriptingJava