# Including external libs in CommandBox CLI doesn't work?

Hello,

I’ve got this cfml script I need to run in which I have to use the Java’s ComputeCRC32 class.

The Jar/Class file for it is under C:\mysite\config\shared\lib\

In CommandBox CLI (v. 5.2.1+00295), I tried adding a global custom lib as described in:

config set servers.defaults.app.libDirs=C:\mysite\config\shared\lib\

Then issuing a config show servers.defaults.app.libDirs shows my set path.

However, even after doing so, when I try my script in the CLI, it fails complaining it cannot find ComputeCRC32 :

CommandBox> execute C:\path\to\myscript.cfm
Error executing C:\path\to\myscript.cfm:
ERROR (5.2.1+00295)

cannot load class through its string name, because no definition for the class with the specified name [ComputeCRC32] could be found caused by (java.lang.ClassNotFoundException:ComputeCRC32;java.lang.ClassNotFoundException:ComputeCRC32 not found by lucee.core [46]
caused by: lucee.commons.lang.ClassException
cannot load class through its string name, because no definition for the class with the specified name [ComputeCRC32] could be found caused by (java.lang.ClassNotFoundException:ComputeCRC32;java.lang.ClassNotFoundException:ComputeCRC32 not found by lucee.core [46]

FYI: I am loading this ComputeCRC class in my script with :

<cfset oMD5 = CreateObject(“java”, “ComputeCRC32”).init()/>

How can I properly have CommandBox CLI load all my custom shared libs? What am I missing ?

UPDATE : I’ve tried simply starting the commandbox server with my required libs folder like so :

server start libDirs=C:\mysite\config\shared\lib\

and yes, this allows me to open my web browser ( http://127.0.0.1:54536/ ), click on myscript.cfm, and it’ll work. No problem loading the ComputeCRC class.

This isn’t what I need though. I need to be able to run it directly as a script in the CLI.

Pat.

Hi, you’re confusing two different features of CommandBox. Well, three actually.

• Starting up a web server. The instructions you were following was exclusive to starting up a server. This won’t have any effect on command-line scripts.
• Doing one-off .cfm executions from the command line. This is an older and very simple method of running CLI code which doesn’t have very may features. I would avoid this in favor of the third bullet.
• Task Runners. These are the modern solution to doing CLI scripting in CFML and have tons of features, including the ability to load arbitrary jars at run time.