Calling a .jar from ColdFusion
-
08-07-2019 - |
Question
I have a .jar file that i've placed in my D:\Coldfusion8\wwwroot\web-inf\lib\ directory. The file is abcdef.jar
This is my first time doing this, not sure what the path should be in my createObject().
<cfset abcObj = createObject("java","com.abcdef") />
<cfset result = acbObj.doStuff("123456") />
But when I run it, I get
Object Instantiation Exception.
Class not found: com.vp4jo_b
What am I missing in the path?
Solution
Have you restarted the Coldfusion Service?
Even when in the class path, jars are only loaded at server start.
Info moved up from the comments:
- Make sure the file is in the System class path, or in the one of the configured class paths of ColdFusion.
- As for the class name parameter of
CreateObject()
: The class name starts within the jar. Open it like a .zip file and look at its structure. The dotted path mimics the folder structure, so if the Server still complains, you must be missing something in the dotted path.
OTHER TIPS
Have you considered using JavaLoader?
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow