When I use Main as the method I get method not found
Java:
package com.alien.enterpriseRFID.examples;
import com.alien.enterpriseRFID.reader.*;
import com.alien.enterpriseRFID.tags.*;
/**
* Connects to a Reader on COM port #1 and asks it to read tags.
*
*/
public class AlienClass1ReaderTest {
/**
* Constructor
*/
public AlienClass1ReaderTest() throws AlienReaderException {
AlienClass1Reader reader = new AlienClass1Reader();
// reader.setConnection("COM1");
// To connect to a networked reader instead, use the following:
reader.setConnection("192.168.1.70", 23);
reader.setUsername("username");
reader.setPassword("password");
// Open a connection to the reader
reader.open();
// Ask the reader to read tags and print them
Tag tagList[] = reader.getTagList();
if (tagList == null) {
System.out.println("No Tags Found");
} else {
System.out.println("Tag(s) found:");
for (int i=0; i<tagList.length; i++) {
Tag tag = tagList;
System.out.println("ID:" + tag.getTagID() +
", Discovered:" + tag.getDiscoverTime() +
", Last Seen:" + tag.getRenewTime() +
", Antenna:" + tag.getAntenna() +
", Reads:" + tag.getRenewCount()
);
}
}
// Close the connection
reader.close();
}
/**
* Main
*/
public static final void main(String args[]){
try {
new AlienClass1ReaderTest();
} catch(AlienReaderException e) {
System.out.println("Error: " + e.toString());
}
}
} // End of class AlienClass1ReaderTest
CF:
<cfset myObj = CreateObject("java", "com.alien.enterpriseRFID.examples.AlienClass1ReaderTest").main()>
Error:
| The following information is meant for the website developer for debugging purposes. |
|
| Error Occurred While Processing Request |
The main method was not found. | | Either there are no methods with the specified method name and argument types or the main 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. | | | Resources: - Enable Robust Exception Information to provide greater detail about the source of errors. In the Administrator, click Debugging & Logging > Debug Output Settings, and select the Robust Exception Information option.
- Check the ColdFusion documentation to verify that you are using the correct syntax.
- Search the Knowledge Base to find a solution to your problem.
| | Browser | Mozilla/5.0 (Windows NT 6.1; WOW64; rv:32.0) Gecko/20100101 Firefox/32.0 | | Remote Address | 192.168.2.4 | | Referrer | | | Date/Time | 04-Sep-14 01:43 PM |
|
|
On the command-line, you would run it like this:
> java -cp C:\ColdFusion10\cfusion\wwwroot\ReaderRFID\lib\AlienRFID.jar AlienClass1ReaderTest
One way to translate this into Coldfusion is:
<cfexecute name="java" arguments="-cp C:\ColdFusion10\cfusion\wwwroot\ReaderRFID\lib\AlienRFID.jar AlienClass1ReaderTest" outputFile="#expandpath('output.txt')#" ></cfexecute>
Java done.
That would run the code and store the output in the current directory as the file output.txt.