我需要将 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>
然后我收到错误
对象实例化异常.找不到类:你好
Object Instantiation Exception. Class not found: Hello
在我的 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 目录中.
You need to put the files on the ColdFusion JVM's classpath, not in its JRE dir.
一般来说,如果你有一个jar文件,把它放在实例的WEB-INF/lib目录,如果它只是一个类,把它放在WEB-INF/classes 目录,例如:对我来说后者是 C:appsadobeColdFusion11fullcfusionwwwrootWEB-INFclasses,其中 C:appsadobeColdFusion11full 是我安装 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:appsadobeColdFusion11fullcfusionwwwrootWEB-INFclasses, where C:appsadobeColdFusion11full is where I installed CF, and cfusion is the name of the instance.
这篇关于如何在 Coldfusion 中使用 java 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
如何在 JTextPane 中的组件周围环绕文本?How to wrap text around components in a JTextPane?(如何在 JTextPane 中的组件周围环绕文本?)
MyBatis,如何获取插入的自动生成密钥?[MySql]MyBatis, how to get the auto generated key of an insert? [MySql](MyBatis,如何获取插入的自动生成密钥?[MySql])
在 Java 中插入 Oracle 嵌套表Inserting to Oracle Nested Table in Java(在 Java 中插入 Oracle 嵌套表)
Java:如何将 CLOB 插入 oracle 数据库Java: How to insert CLOB into oracle database(Java:如何将 CLOB 插入 oracle 数据库)
为什么 Spring-data-jdbc 不保存我的 Car 对象?Why does Spring-data-jdbc not save my Car object?(为什么 Spring-data-jdbc 不保存我的 Car 对象?)
使用线程逐块处理文件Use threading to process file chunk by chunk(使用线程逐块处理文件)