Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

java, coldfusion and pathnames 1

Status
Not open for further replies.

jimmyshoes

Programmer
Jun 1, 2008
132
0
0
GB
I have created a simple java object which takes a string and creates a file
Code:
File newFile = new File(str)
This java object has been placed in the jre/lib directory

I intend to call this object using createObject() as follows
Code:
<cfset obj = createObject("java","fileCreator") />
<cfset obj.init(theFileName) />

The init() function passes on the fileName to create the file object

My question is, what should theFileName be
1. If I want a relative pathname, will the pathname be relative to jre/lib
2. If I want to pass an absolute pathname should I use expandPath()
 
It all depends on what your class is doing. But usually an absolute path is best.

But I am curious. Is there a reason you need to create your own java class rather than a) using CF file functions or b) using java directly from ColdFusion?

----------------------------------
 
I had real difficulty calling my java class from Coldfusion 8 and Coldfusion 9 with createObject(). Coldfusion 8 wouldn't instantiate and Coldfusion 9 wouldn't let me pass any parameters to the java method I had written( it said that no function existed in Java with those arguments ). i did a lot of googling and found many others have had problems in this area. I eventually decided to use CF functions ( xmlParse() etc) and it all works fine now
 
Well, the error messages are not always the best ;) But usually problems boil down to a few causes. If you cannot create the object it usually means CF cannot find the class, or you forgot to restart the server after adding it to your path. Common causes of the 'method not found' error are ambiguity in argument types OR when you forget to make the class or method public so CF does not have access to it.

Anyway, I am glad you found a working option.



----------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top