Blog

Brad Wood

July 05, 2013

Spread the word


Share your thoughts

If you're using external Jar files in your project, you may be loading them at run time with Mark Mandel's JavaLoader project.  (CF10 allows for dynamic loading of Jar files, but for people still on CF8, or 9, JavaLoader is the defacto method)
If you're manually creating and using the JavaLoader CFC, please remember that WireBox has a dedicated "JavaLoader" namespace in its mapping DSL to handle this for you using ColdBox's JavaLoader Plugin.  Here all you have to do:

Put a javaloader_libpath setting in your config file that tells ColdBox where the your Jars are:

ColdBox.cfc
// custom settings
settings = {
    javaloader_libpath = "/includes/jars/"
};

If you have more than one Jar directory, simply pass in a comma-delimited list, OR an array of paths.  Your choice.

Now you can inject that class into your components by using the "javaloader" namespace and following it by the Java classpath:

component {
    property name="UASparser" inject="javaLoader:cz.mallat.uasparser.UASparser";
}

That will inject the Java Class definition (which is fine for static classes).  If you need an instance, you'll want to call the init() method to actually instantiate it.

function onDIComplete() {
    oUASparser = UASparser.init(ExpandPath("/includes/uas.ini"));
}

That's not the only way-- this one-liner accomplishes the same thing:

oUASparser = getModel(dsl="javaloader:cz.mallat.uasparser.UASparser").init(ExpandPath("/includes/uas.ini"));

More info here: http://wiki.coldbox.org/wiki/Plugins:JavaLoader.cfm
And here: http://wiki.coldbox.org/wiki/WireBox.cfm#ColdBox_Namespace

Add Your Comment

(2)

Dec 09, 2014 10:39:20 UTC

by Daniel

How to add javaloader_libpath in wirebox standalone..?

Dec 09, 2014 12:11:15 UTC

by Brad Wood

The "javaloader" DSL namespace is only available in WireBox when it is linked to ColdBox. That's because it depends on the JavaLoader Plugin which is part of ColdBox. Note: in ColdBox 4, JavaLoader has been removed from the ColdBox core and is an optional module called cbjavaloader. So you can't use the DSL I showed in this post by default, HOWEVER you can add this into WireBox standalone if you wish. Look at how the cbjavaloader module works-- it registers the "javaloader" DSL on the fly. https://github.com/ColdBox/cbox-javaloader/blob/master/modules/cbjavaloader/ModuleConfig.cfc#L26 You could probably make a standalone version of cbjavaloader that reused the same loader object and registered the DSL. Honestly though, i would save my time and just start using ColdBox :) Using JavaLoader in ColdBox 4 is as simple as this: CommandBox> install cbjavaloader Done!

Recent Entries

Ortus Monthly Digest: June 2025

Ortus Monthly Digest: June 2025

June was a transformative month at Ortus Solutions as we crossed the halfway point of the year. With major product updates, powerful community engagements, and continued improvements across the BoxLang ecosystem, our mission to modernize development and empower engineers took center stage. Whether you're a longtime member of the Ortus community or just joining us, here's everything we accomplished in June packed with announcements, tools, and opportunities to grow.

Victor Campos
Victor Campos
July 08, 2025
Ortus Solutions Shines at the 10th América Digital Congress Mexico 2025

Ortus Solutions Shines at the 10th América Digital Congress Mexico 2025

Ortus Solutions had the honor of participating in the prestigious 10th América Digital Congress Mexico 2025, one of the most important technology events in Latin America. Invited by INVEST in El Salvador as part of the official national delegation, our team proudly represented El Salvador’s growing tech sector while showcasing our cutting-edge innovations and bold technological vision for the region.

Connecting with Latin America's Di...

Cristobal Escobar
Cristobal Escobar
July 07, 2025
BoxLang TextMate Bundle Has Landed

BoxLang TextMate Bundle Has Landed

We're excited to announce the release of the BoxLang TextMate Bundle — a comprehensive development toolkit that brings world-class IDE support to BoxLang developers using TextMate, VS Code, Sublime Text, and other TextMate-compatible editors. With BoxLang 1.0 now stable and rapidly gaining momentum in the JVM ecosystem, professional tooling has never been more critical. This bundle delivers exactly that, providing everything you need to build modern, dynamic applications with BoxLang's powerful multi-runtime capabilities.

Luis Majano
Luis Majano
July 07, 2025