You'll probably never need to do this, but today, I needed to find out what Java classes were available in a given JAR file using ColdFusion. The reason - I was doing some work on my POI Utility ColdFusion custom tags and I needed to see if the version of the POI JAR that ships with ColdFusion supports certain classes. Turns out, this is a fairly straightforward task. I wrapped the functionality up in a ColdFusion user defined function that takes the expanded path to the target JAR file:
Launch code in new window » Download code as text file »
To call it, you just do this (I had a copy of the installed POI JAR file in the same directory as my test file):
Launch code in new window » Download code as text file »
Running this, we get an array with the following values (abbreviated):
org.apache.poi.ddf.DefaultEscherRecordFactory
org.apache.poi.ddf.EscherArrayProperty
org.apache.poi.ddf.EscherBSERecord
org.apache.poi.ddf.EscherBlipRecord
..... several hundred classes .....
org.apache.poi.util.ShortList
org.apache.poi.util.StringUtil
org.apache.poi.util.SystemOutLogger
Anyway, just thought I would post that in case anyone ever needs this kind of functionality.
Download Code Snippet ZIP File
Comments (5) | Post Comment | Ask Ben | Permalink | Other Searches | Print Page
Listing All Classes In A Jar File Using ColdFusion And CFZip
Project HUGE: Trying Out A 4-Exercise Limit
How is this different then just listing the JAR out with cfzip?
Posted by todd sharp on Oct 3, 2008 at 9:09 AM
I never really play around with JAR files much, so this comment could be totally off base, but, could you have not just used the cfzip tag? It accepts a JAR file and you could use the list action and just dumped that out, right? or am i missing the point? It's Friday so my brain has shut of ffor the weekend :-)
Posted by Simon Free on Oct 3, 2008 at 9:10 AM
@Todd - beat me to it :-)
Posted by Simon Free on Oct 3, 2008 at 9:10 AM
@Todd, @Simon,
Oh snap, I totally forgot that CFZip could read JAR files :)
Posted by Ben Nadel on Oct 3, 2008 at 9:13 AM
Thanks guys; amends have been made:
http://www.bennadel.com/index.cfm?dax=blog:1373.view
Posted by Ben Nadel on Oct 3, 2008 at 9:30 AM