你如何在Coldfusion中使用java文件 [英] How do you use java files in Coldfusion

查看:37
本文介绍了你如何在Coldfusion中使用java文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆