In java using this.getClass().getResource(""); will result in a jar:file:/ etc url ending with yourjarfile.jar!/internal/package/path/ this regular expression matches the directory before the internal jar path declaration returning the physical directory the file resides in. should work in both posix and windows machines (untested for posix*) |