Include Java Files into Coldfusion

2019-04-08 14:25发布

How can I include jar/java files into my coldfusion project. currently I am using this line into me <cfscript>

Me directory is looks like this

website_name
         |__ Login
             |__ connection
                |__ display.cfm
                |__ twitter
                    |__ com
                        |__ ConfigurationBuilder.java

in my display.cfm file I am calling obj in script like this

<cfscript>
    configBuilder = createObject("java", "twitter.com.ConfigurationBuilder");
</cfscript>

but it gives me error on this line when I run display.com and error is this

An exception occurred while instantiating a Java object. The class must not be 
an interface or an abstract class. Error: ''. 

The error occurred in website_name/login/azam/connection/display.cfm: line 57


57 :            configBuilder = createObject("java", "twitter.com.ConfigurationBuilder");

How can I call my java class and how to call its function so that I can call my twitter function.

4条回答
老娘就宠你
2楼-- · 2019-04-08 14:57

ColdFusion 9 here:

  1. Put jars into: wwwroot/WEB-INF/lib
  2. Put classes into: wwwroot/WEB-INF/classes (class mypackage.myClass goes into subdirectory mypackage)
查看更多
不美不萌又怎样
3楼-- · 2019-04-08 15:01

If you're using ColdFusion 10 you can use the newly built in feature to dynamically load Java Files:

Specifying custom Java library path in the Application.cfc

查看更多
我想做一个坏孩纸
4楼-- · 2019-04-08 15:14

As surfealokesea said in their answer:

The easiest way to add class or jar files to your class path is to simply drop them in the lib directory where they are automatically picked up. The directory is located at

CF Directory(where CF is installed)
                             |__ servers/lib

These class files will be available to all servers.

You can also make your class files available only to the ColdFusion server by dropping them in

{cf_installation}/servers/default/cfmx/WEB-INF/lib.

(Note that putting them in {cf_installation}/servers/default/cfmx/WEB-INF/cfusion/lib will NOT work.)

查看更多
Rolldiameter
5楼-- · 2019-04-08 15:20

The easiest way to add class or jar files to your class path is to simply drop them in the lib directory where they are automatically picked up. The directory is located at {cf_installation}/servers/lib. These class files will be available to all servers.

http://blogs.adobe.com/cantrell/archives/2004/07/the_definitive.html

查看更多
登录 后发表回答