I want to create an instance of JasperReportBuilder so that I can use it in my function reportAddTitle() without passing it through the function like reportAddTitle(report, component)
When I try to make it public eclipse tells me this:

My program (overly simplifyed of course):
public class myProgram {
void makeReport(String args[]) {
public JasperReportBuilder report = DynamicReports.report();
}
public void reportAddTitle (ComponentBuilder component) throws JRException{
report.addTitle(component);
}
}
How can I define the instance report of type JasperReportBuilder as public?
You can't define public variables within a method, variables define in method will only exists in method.
The solution is to define it outside or pass it as parameter
As you see it does not even need to be public, public is to allow access from other classes not in package and general in java we like to use getters and setters to control this access.