geonames exception - 由以下引起:java.lang.ClassNotFoundException:org.jdom.input.SAXBuilder

时间:2012-05-23 14:32:50

标签: exception noclassdeffounderror geonames

我正在尝试运行一个软件,如果一个实体是地理的,我可以用它来建立:

public boolean isgeo(String e) throws Exception{

    ToponymSearchCriteria searchCriteria = new ToponymSearchCriteria();
    searchCriteria.setNameEquals(e);
    ToponymSearchResult searchResult = WebService.search(searchCriteria);
    entity = (ArrayList) searchResult.getToponyms();
    for (Toponym toponym : searchResult.getToponyms()) {
         System.out.println(toponym.getName()+" "+ toponym.getCountryName());
      }

    if(entity.size()>0)
        return true;
    else
        return false;

}

但是当我调用这个函数时,我有以下例外:

Exception in thread "main" java.lang.NoClassDefFoundError: org/jdom/input/SAXBuilder
at org.geonames.WebService.connectAndParse(Unknown Source)
at org.geonames.WebService.search(Unknown Source)
at geonames.utility.isgeo(utility.java:35)
at geonames.main.main(main.java:31)
Caused by: java.lang.ClassNotFoundException: org.jdom.input.SAXBuilder
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)

任何人都可以帮助我吗?

1 个答案:

答案 0 :(得分:1)

你需要jdom-1.0 jar。不要下载任何其他版本,因为它不起作用。将此jar文件添加到您的项目中。