Q:

Java: unable to access static singleton method

i am facing one problem.i have a class named "ReportingService" and it should be singleton and is is extending "CommonService".
package MyApp.Services.ReportingService;

public class ReportingService extends CommonService {

    private static ReportingService instance = null;

    public static ReportingService getInstance() {
        if (instance == null) {
            instance = new ReportingService();
        }
        return instance;   

    }
}

and to access this class in other class i am using 
package MyApp.Services.WebReportingService;
@WebMethod(operationName = "registerUDP")
    public boolean registerUDP(
            @WebParam(name = "Friendly Name") String friendlyName,
            @WebParam(name = "Username") String username,
            @WebParam(name = "Password") String password,
            @WebParam(name = "Communication Protocol") CommunicationProtocol communicationProtocol,
            @WebParam(name = "IP Address") String ipAddress,
            @WebParam(name = "Port") int port) {

        Consumer client = new Consumer(friendlyName, username, password, communicationProtocol, ipAddress, port);

ReportingService rs = ReportingService.
        return true;

    }

in "ReportingService rs = ReportingService." it is not showing me getInstance() method of ReportingService class. I also imported correct packages.
NOTE: both classes are in different packages.

A:

Change as follows:
package MyApp.Services.ReportingService;  // FIXME - Make package names lowercase!!
                                          // FIXME - Loopy package name

public class ReportingService extends CommonService {

    private static ReportingService instance = null;

    private ReportingService() { }

    public static synchronized ReportingService getInstance() {
        if (instance == null) {
            instance = new ReportingService();
        }
        return instance;   

    }
}

and 
import MyApp.Services.ReportingService.ReportingService; 

package MyApp.Services.WebReportingService ; 
                        // FIXME - Make package names lowercase!!
                        // FIXME - Loopy package names.

public class WebReportingService {

    @WebMethod(operationName = "registerUDP")
    public boolean registerUDP(
            @WebParam(name = "Friendly Name") String friendlyName,
            @WebParam(name = "Username") String username,
            @WebParam(name = "Password") String password,
            @WebParam(name = "Communication Protocol") CommunicationProtocol communicationProtocol,
            @WebParam(name = "IP Address") String ipAddress,
            @WebParam(name = "Port") int port) {

        Consumer client = new Consumer(friendlyName, username, password,
                                       communicationProtocol, ipAddress, port);

        ReportingService rs = ReportingService.getInstance();
        return true;
    }
}

Note: depending on which packages the Consumer and CommunicationProtocol classes are defined in, you may need to import them; e.g. add these lines before the package line.
import some.package.Consumer;
import some.other.package.CommunicationProtocol;

Note 2: your current choice of package names has some seriously style issues.

package names should be all lowercase
the prefix of your package names should be the (reversed) DNS-style identifier for your company, organization, whatever; e.g. in.com.yourcompany....  Note, there are very good reasons form this convention!!
MyApp / myapp is content free and shouldn't be used
services.reportingservice is redundant / verbose; e.g. use services.reporting instead
using the same name as a class and package name is redundant / verbose
unless there are lots of classes in the reporting and webreporting packages, they probably should be folded into one package.  Lots of packages with 1 or 2 classes in them is not helpful.

A:

I think your package names are broken. You seem to have the name of the class at the end of the package - but the name of the class only appears when you import.
So you would have :
package myApp.Services;

public class ReportService extends CommonService {/* code goes here */}

but then you would include:
import myApp.Services.ReportService;

Same goes for the WebReportingService. The package statement should not include the class name
Edit: if you actually want ReportService in package myApp.Services.ReportService, then you need to import myApp.Services.ReportService.ReportService (or, alternatively, myApp.Services.ReportService.*, but this is not recommended unless you need many classes from the package)

