java - referencing data files in jars -


my java program references lot of data files. put them in top level directory called data/, along src/ , bin/. in eclipse, references data/ , ../data/ both seem work. when run command line, ../data/ works.

when put bin/ , data/ directories in jar , correctly set entry point, doesn't seem know want access data/ directory inside jar. way i've been able work setting references ../data/ , placing jar in bin directory. doesn't me good, because it's not self-contained.

what need references make them work?

thanks

i'd recommend access files in classpath-relative way, whether in eclipse or in compiled jar.

there few ways might go it, basic jdk-only approach use class's getresourceasstream() method, giving access inputstream object can read in.


Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -