問(wèn)題描述
我需要將 java 文件導(dǎo)入 Coldfusion 8 頁(yè)面,例如:
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>
然后我收到錯(cuò)誤
對(duì)象實(shí)例化異常.找不到類(lèi):你好
Object Instantiation Exception. Class not found: Hello
在我的 Coldfusion 服務(wù)器中,Java 虛擬機(jī)路徑設(shè)置為C:/ColdFusion8/runtime/jre",所以這是我放置 java 文件的位置,對(duì)嗎?我應(yīng)該在里面放一個(gè) .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?
文件名需要和類(lèi)名一致嗎?
Does the file name need to be consistent with class name?
有沒(méi)有人可以嘗試類(lèi)似的工作示例代碼?
Does anyone have working sample code for something similar I can try?
推薦答案
您需要將文件放在 ColdFusion JVM 的類(lèi)路徑中,而不是其 JRE 目錄中.
You need to put the files on the ColdFusion JVM's classpath, not in its JRE dir.
一般來(lái)說(shuō),如果你有一個(gè)jar文件,把它放在實(shí)例的WEB-INF/lib
目錄,如果它只是一個(gè)類(lèi),把它放在WEB-INF/classes
目錄,例如:對(duì)我來(lái)說(shuō)后者是 C:appsadobeColdFusion11fullcfusionwwwrootWEB-INFclasses
,其中 C:appsadobeColdFusion11full
是我安裝 CF 的地方,cfusion
是實(shí)例的名稱(chēng).
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.
這篇關(guān)于如何在 Coldfusion 中使用 java 文件的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!