问题描述
我需要导入一个java文件到coldfusion 8页例如。 :
I need to import a java file into a coldfusion 8 page e.g. :
public class Hello
{
public String testJava()
{
return "Hello Java!!";
}
}
在Coldfusion中,我有以下代码:
In Coldfusion I have the following code:
<cfscript>
helloWorld = CreateObject("java","Hello");
helloTest = helloWorld.testJava();
</cfscript>
然后我收到错误
在我的ColdFusion服务器中,Java虚拟机路径设置为C:/ ColdFusion8 / runtime / jre所以这是我把我的java文件,这是正确的地方?我应该把.java,.class还是.jar放在那里?
In my Coldfusion server Java Virtual Machine Path is set to 'C:/ColdFusion8/runtime/jre', So this is where I have put my java file, is this correct? Should I put a .java, .class or .jar there?
文件名是否需要与类名一致?
Does the file name need to be consistent with class name?
有没有人有类似的工作示例代码可以尝试?
Does anyone have working sample code for something similar I can try?
推荐答案
在ColdFusion JVM的类路径,而不是在它的JRE dir。
You need to put the files on the the ColdFusion JVM's classpath, not in its JRE dir.
一般来说,如果你有一个jar文件,把它放在实例的 WEB-INF / lib
dir,如果它只是一个类,将它放在 WEB-INF / classes
目录中,例如:将 C:\apps\adobe\ColdFusion\11\full\cfusion\wwwroot\WEB-INF \classes
,其中 C:\apps\adobe\ColdFusion\11\full\
是我安装CF的地方, cfusion
是实例的名称。
As a rule, if you have a jar file, put it in the instances's WEB-INF/lib
dir, if it's just a class, put it in the WEB-INF/classes
dir, eg: for me the latter would be C:\apps\adobe\ColdFusion\11\full\cfusion\wwwroot\WEB-INF\classes
, where C:\apps\adobe\ColdFusion\11\full\
is where I installed CF, and cfusion
is the name of the instance.
这篇关于如何在Coldfusion中使用java文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!