Include Java files in Coldfusion

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

Catalog

Me looks like this:

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

in my display.cfm file, I call obj in a script like this

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

but it gives me an error in this line when I run display.com , and an error in 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
source share
4 answers

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

+3
source

If you are using ColdFusion 10, you can use the recently built-in function to dynamically load Java files:

Specifying a custom Java library path in Application.cfc

+2
source

As surfealokesea said in their answer :

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

 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 placing them in {cf_installation} / servers / default / cfmx / WEB-INF / cfusion / lib will NOT work.)

+2
source

ColdFusion 9 is here:

  • Insert jars in: wwwroot/WEB-INF/lib
  • Put the classes in: wwwroot/WEB-INF/classes (the mypackage.myClass class goes into the mypackage subdirectory)
0
source

Source: https://habr.com/ru/post/1488875/


All Articles