你如何在Coldfusion中使用java文件 [英] How do you use java files in Coldfusion
问题描述
I need to import a java file into a coldfusion 8 page e.g. :
public class Hello
{
public String testJava()
{
return "Hello Java!!";
}
}
In Coldfusion I have the following code:
<cfscript>
helloWorld = CreateObject("java","Hello");
helloTest = helloWorld.testJava();
</cfscript>
I then receive the error
Object Instantiation Exception. Class not found: Hello
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?
You need to put the files on the ColdFusion JVM's classpath, not in its JRE dir.
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:appsadobeColdFusion11fullcfusionwwwrootWEB-INFclasses
, where C:appsadobeColdFusion11full
is where I installed CF, and cfusion
is the name of the instance.
这篇关于你如何在Coldfusion中使用java文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!