-3

我对 maxmind API 有疑问。我用一些例子来测试。但是,运行时错误“no main function public static void main(String[] args)”我很困惑,我已经知道public static void main了。

public class GetLocationExample {


    public static void main(String[] args) {

        try {
            LookupService lookup = new LookupService("D:\\GeoLiteCity.dat\\GeoLiteCity.dat",LookupService.GEOIP_MEMORY_CACHE);
            Location locationServices = lookup.getLocation("140.118.175.207");
            System.out.println("# country code: " + locationServices.countryCode);
            System.out.println("# country name: " + locationServices.countryName);
            lookup.close();
        }
        catch (IOException e) {
            System.out.println("IO Exception");
        }

    }
}
4

1 回答 1

0

您当然只需要String[]在 main 方法中添加参数:

public static void main(String[] args){
    // The content of your main method
}
于 2013-10-29T22:54:48.367 回答