0

我的主要代码有两个类,主要有两个引用

LookupService citylookup = new LookupService("D://GeoLiteCity.dat"...
FileReader fr =new FileReader("d:\\IP.txt");

我将它们导出到一个可执行的 jar 文件中,然后我得到D://testIP.jarD://testIP_lib/reference libraries...jar

我跑java -jar testIP.jar,它工作。

但是,我修改了我对 linux 机器路径 ex: 的引用:/home/admin/GeoLiteCity.dat and/home/admin/IP.txt并移动textIP.jarandtestIP_libGeoLiteCity.dat IP.txt再次/home/admin/ 运行java -jar testIP.jar我得到错误

Exception in thread "main" java.lang.NoClassDefFoundError: com/maxmind/geoip/LookupService
    at testIP.CountryLookupTest.main(CountryLookupTest.java:18)

我检查它们是 java 1.7..version 我不知道我应该在哪里设置?谢谢你。

4

2 回答 2

2

听起来像是两个环境之间的类路径差异。检查CLASSPATH两个环境中的环境变量,并检查jarClass-Path中文件中的条目。MANIFEST.MF我怀疑 Eclipse 在 jarClass-Path内的 Manifest 文件中使用基于 Windows 的条目构建了 jar。

于 2013-11-12T20:20:52.627 回答
1

如果这有任何帮助。

http://docs.oracle.com/javase/7/docs/technotes/tools/windows/classpath.html

http://docs.oracle.com/javase/7/docs/technotes/tools/solaris/classpath.html

您将不得不查看如何在 Linux 环境中使用类路径。

于 2013-11-12T20:22:07.423 回答