通过 ColdFusion 访问 JNI DLL 中的功能
我尝试使用 ColdFusion 中的 CreateObject 函数通过 JNI 访问 DLL 中的功能。我已经设法让 ColdFusion 使用 java.lang.System.load 函数加载 DLL,但我不确定如何访问此方法中包含的函数。
我当前的代码:
<cfset CreateObject("java","java.lang.System").load("C://Path//To//JniDll.dll")>
<cfset JniObject = CreateObject("java","Organisation.product.package")>
在第 2 行失败并出现错误
Object Instantiation Exception.
Class not found Organisation.product.package
我可能错误地访问了这些方法,但无法在网络上找到有关在 ColdFusion 中使用 JNI 的任何信息。
谢谢你的帮助,
汤姆
I'm attempting to use the CreateObject
function within ColdFusion to access functionality within a DLL through JNI. I've managed to get ColdFusion to load the DLL OK using the java.lang.System.load function, but am not sure how to then access the functions contained within this method.
My current code:
<cfset CreateObject("java","java.lang.System").load("C://Path//To//JniDll.dll")>
<cfset JniObject = CreateObject("java","Organisation.product.package")>
Which fails on line 2 with the error
Object Instantiation Exception.
Class not found Organisation.product.package
It's possible I'm accessing these methods incorrectly, but haven't been able to find any information about using JNI in ColdFusion on the web.
Thanks for your help,
Tom
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
AFAIK 仅通过注册您将无法访问该 DLL 中的方法。要么您获得一个 Java 包装器(可能作为 JAR),然后它将使用 DLL,要么您必须查看 DLL 公开的 COM 接口并通过 createobject(type="COM") 调用它们,正如其他人所建议的那样。
从代码和错误的外观来看,您期望存在一个 Java 类 Organization.product.package,而 CF 看不到它,所以我会在 CF 管理器中查看一下,看看您的目录中有哪些路径类路径。将 JAR(我假设您已将其放入 CF 的 lib 文件夹中)放入 CF 的 lib 文件夹中,然后重新启动 CF,看看这是否会产生影响。
You won't get access to the methods in that DLL just by registering it AFAIK. Either you get supplied a Java wrapper (probably as a JAR) which will then use the DLL, or you have to see what COM interfaces the DLL exposes and call them via createobject(type="COM"), as others have suggested.
From the looks of your code and error, you're expecting a Java class Organisation.product.package to be present and CF can't see it, so I'd take a look in the CF administrator and see which paths are in your classpath. Drop the JAR I assume you have into CF's lib folder and restart CF and see if that makes a difference.
我建议你先让它在java中工作。之后,将生成的 jar 文件放置在正确的 Coldfusion lib 目录中,并使用 CreateObject 加载(java 类)。 java类应该负责dll绑定。
I would suggest you make it work in java first. After that you place the generated jar file in the correct coldfusion lib directory and load (the java class) using CreateObject. The java class should be responsible for the dll binding.