The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages - More
> ColdFusion Development
|
Loading Java JAR's in CF10
Discuss Loading Java JAR's in CF10 in the ColdFusion Development forum on Dev Shed. Loading Java JAR's in CF10 ColdFusion Development forum discussing CFML coding practices, tips on CFML, and other CFML related topics. Find out why ColdFusion is the tool of choice for many e-commerce developers.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

May 26th, 2012, 04:59 PM
|
|
Registered User
|
|
Join Date: Feb 2012
Posts: 29
Time spent in forums: 10 h 56 m
Reputation Power: 0
|
|
|
Loading Java JAR's in CF10
I'm trying to load the Docx4j JAR file. But I keep getting a class not found... even though I specified where the JAR is located in the Application.cfc:
Code:
<cfcomponent output="false">
<cfset this.javaSettings =
{LoadPaths = ["/myJava/lib"], loadColdFusionClassPath = true, reloadOnChange= true,
watchInterval = 100, watchExtensions = "jar,class,xml"} />
</cfcomponent>
EDIT:
http://www.docx4java.org/trac/docx4j
When dealing with JAR's I am guessing we use dot notation to transverse and find the class that we need?
This doesn't work:
Code:
<cfset docObj = createObject("java","org.docx4j.openpackaging.packages.WordprocessingMLPackage") />
|

May 29th, 2012, 06:42 PM
|
|
Moderator
|
|
Join Date: Jun 2002
Location: Raleigh, NC
|
|
|
Yes, that's the right syntax. You'll need to be sure the method exists, that you're passing any required parameters into the constructor (if there are any constructor args), and that they are of the proper Java type.
I actually haven't tried the new class loader in CF 10 though.
|

May 29th, 2012, 06:43 PM
|
|
Moderator
|
|
Join Date: Jun 2002
Location: Raleigh, NC
|
|
|
You might try specifying an absolute path to the library folder to make sure it's pointing where you think it should be.
|

May 30th, 2012, 11:30 PM
|
|
Registered User
|
|
Join Date: Feb 2012
Posts: 29
Time spent in forums: 10 h 56 m
Reputation Power: 0
|
|
Ah, I got it to work now. These objects require the init() constructor to be supplied to them.
Code:
<cfset docObj = createObject("java","org.docx4j.openpackaging.parts.WordprocessingML.MainDocumentPart").init() />
<cfset docPackageObj = createObject("java","org.docx4j.openpackaging.packages.WordprocessingMLPackage").init() />
This is actually, very good news since it is telling me that CF10 can actually work around class loading issues.
|

May 30th, 2012, 11:48 PM
|
|
Moderator
|
|
Join Date: Jun 2002
Location: Raleigh, NC
|
|
This has actually been available for a while as an open-source add on called JavaLoader. Adobe just realized it was very useful and incorporated it with some modifications. 
|

June 4th, 2012, 09:16 PM
|
|
Contributing User
|
|
Join Date: May 2008
Posts: 117
Time spent in forums: 17 h 16 m 2 sec
Reputation Power: 6
|
|
Quote: | Originally Posted by kiteless This has actually been available for a while as an open-source add on called JavaLoader. Adobe just realized it was very useful and incorporated it with some modifications.  |
Do you know what modifications were made or where to find the official documentation on this feature? I was curious how it differs from the javaLoader, but my google must be broken because I am coming up with zip... ;-)
|

June 5th, 2012, 12:51 AM
|
|
Moderator
|
|
Join Date: Jun 2002
Location: Raleigh, NC
|
|
|
I'm actually not sure. I don't think it was anything major though, just tighter integration with CF (obviously, heh).
|

June 5th, 2012, 08:24 AM
|
|
Contributing User
|
|
Join Date: May 2008
Posts: 117
Time spent in forums: 17 h 16 m 2 sec
Reputation Power: 6
|
|
Yeah, Mark Mandel must be so proud
Finally found some documentation on it here:
http://help.adobe.com/en_US/ColdFusion/10.0/Developing/WSe61e35da8d318518-106e125d1353e804331-7ffe.html
|

June 5th, 2012, 08:48 AM
|
|
Moderator
|
|
Join Date: Jun 2002
Location: Raleigh, NC
|
|
I know Mark pretty well and he's actually not super thrilled about having all that work appropriated heh. Ah, the perils of open source. 
|

June 5th, 2012, 09:41 AM
|
|
Contributing User
|
|
Join Date: May 2008
Posts: 117
Time spent in forums: 17 h 16 m 2 sec
Reputation Power: 6
|
|
Quote: | Originally Posted by kiteless I know Mark pretty well and he's actually not super thrilled about having all that work appropriated heh. Ah, the perils of open source.  |
Having used every one of the javaLoader's incarnations, I do not blame him. It is a fantastic piece of work. (If you could hear my tone, the "proud" comment was injected with a wealth of sarcasm 
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|