Tuesday, November 13, 2007

Cannot make a static reference to the non-static method

ComponentMap cm = GenericRDSFactory.getRDSComponents(rr);


(where GenericRDSFactory is a different class): gives the error

"Cannot make a static reference to the non-static method":

The static keyword just means that the method or attribute belongs to that class.

The solution: instantiate the class first, then invoke the methods from the new object.

GenericRDSFactory factory = new GenericRDSFactory();

ComponentMap cm = factory.getRDSComponents(rr);

No comments: