user2166307
user2166307

Reputation:

Include Java Files into Coldfusion

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.

Upvotes: 5

Views: 4660

Answers (4)

Roland
Roland

Reputation: 7853

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)

Upvotes: 0

user2701037
user2701037

Reputation:

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.)

Upvotes: 2

BigMadKev
BigMadKev

Reputation: 2430

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

Upvotes: 2

surfealokesea
surfealokesea

Reputation: 5116

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

Upvotes: 3

Related Questions