Search code examples
javaeclipsejarrunnable

Resource in src folder not included in Jar


I am generating a Runnable Jar file using Eclipse. But when I am testing it out, it gives me an unsatisfied link error. This is because it is missing a resource, but this resource is located in the src folder. Wich is obviously added to the Java build path. How can I fix this?

Code:

    final URL geoDBFileURL = GeoIPServiceImpl.class.getResource("GeoIP.dat");
    if (geoDBFileURL == null) {
        return null;
    }

Stacktrace:

Exception in thread "main" java.lang.IllegalStateException: No default GeoIP dat
abase file found
        at oast.geoip.GeoIPServiceImpl.<init>(GeoIPServiceImpl.java:20)
        at oast.Oast.initialize(Oast.java:409)
        at oast.Oast.main(Oast.java:434)

Solution

  • I think you should put it in the resources folder instead of the src folder, here is a similar problem: How to export jar with images on Eclipse?