java 从 ColdFusion 调用 .jar
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/295811/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Calling a .jar from ColdFusion
提问by Gene R
I have a .jar file that i've placed in my D:\Coldfusion8\wwwroot\web-inf\lib\ directory. The file is abcdef.jar
我在 D:\Coldfusion8\wwwroot\web-inf\lib\ 目录中有一个 .jar 文件。该文件是 abcdef.jar
This is my first time doing this, not sure what the path should be in my createObject().
这是我第一次这样做,不确定我的 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?
我在路上错过了什么?
采纳答案by Tomalak
Have you restarted the Coldfusion Service?
您是否重新启动了 Coldfusion 服务?
Even when in the class path, jars are only loaded at server start.
即使在类路径中,jar 也仅在服务器启动时加载。
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.
- 确保该文件位于 System 类路径中,或位于 ColdFusion 的已配置类路径之一中。
- 至于类名参数
CreateObject():类名在jar中开始。像 .zip 文件一样打开它并查看其结构。虚线路径模仿文件夹结构,所以如果服务器仍然抱怨,你一定在虚线路径中遗漏了一些东西。
回答by Adam Tuttle
Have you considered using JavaLoader?
您是否考虑过使用JavaLoader?

