We help IT Professionals succeed at work.

Coldfusion 8 trying to extend using java jar files

roger v
roger v asked
on
Hello all,

I have cf8 on my laptop (developer edition). I created a simple java class(dataGeneration)  in eclipse, compiled it, exported it into .jar files and placed it in C:\Coldfusion8\wwwroot\WEB-INF\lib, restarted CF application service, but got an error when I try to do createObject("java", "dataGeneration");
in my .cfm page. So I entered the complete path in classpath setting in CF administrator, restarted, but the error still pops up.

I know it's something simple but I'm still not clear on the whole topic of how to specify a java .jar file that is already being picked up by coldfusion. How do I correctly instantiate the java object/.jar file?
Comment
Watch Question

Kevin CrossChief Technology Officer
Most Valuable Expert 2011

Commented:
Is your dataGeneration class in a specific package ? If so, you should fu lly qualify the name. Also check that the class name is not really DataGeneration as that would be more appropriate by naming conventions.
e.g., package mypackage;
createObject("java", "mypackage.DataGeneration");
Commented:
@mwvisa1:

No, my dataGeneration class is not in any package. You're correct, I had the class and file names wrong. I changed them but still keep getting the error. Here is what I have:

.JAR file:

C:\Coldfusion8\wwwroot\WEB-INF\lib\dataGeneration.jar

Source and class files in the jar:
FibonacciNumbers.java, FibonacciNumbers.class

Class path in coldfusion administraotr:
C:\Coldfusion8\wwwroot\WEB-INF\lib

The object instantiation error (Class not found: dataGeneration.fibonacciNumbers) is generated by:
<cfscript>
      myObj = createObject("java","dataGeneration.fibonacciNumbers");

</cfscript>

<cfdump var="#myObj#">

What should my createObject() be like?


roger