I have a .cfm
file with the following code:
<cfset myObj=CreateObject( "java", "Test" )/>
<cfset a = myObj.init() >
<cfoutput>
#a.hello()#
</cfoutput>
<cfset b = a.testJava() >
<cfoutput>
#testJava()#
</cfoutput>
This references a Java
class file:
public class Test
{
private int x = 0;
public Test(int x) {
this.x = x;
}
public String testJava() {
return "Hello Java!!";
}
public int hello() {
return 5;
}
}
I get the error:
The hello method was not found.
Either there are no methods with the specified method name and argument types or the hello method is overloaded with argument types that ColdFusion cannot decipher reliably.
ColdFusion found 0 methods that match the provided arguments. If this is a Java object and you verified that the method exists, use the javacast function to reduce ambiguity.
I have tried many different ways and have followed the documentation exactly, here. The .class
file is in the correct location because I FNF error is thrown if the file is removed.
I have also attempted using a cfobject
tag in a similar manner with no luck. None of the methods are found. Any ideas?
Coldfusion 11, Hotfix 7