3

I am reading a *.properties file using properties.load and a file name.

I want to add the properties file to the jar or to the classpath.

  1. How do add a file to the jar?
  2. How do I read from the jar?
Rob Kielty
  • 7,740
  • 7
  • 37
  • 50
Bick
  • 16,965
  • 49
  • 140
  • 240

1 Answers1

8

Place the file in the source folder, it will be copied to the output and added to the jar together with the classes according to Settings | Compiler | Resource Patterns.

To load the file in your app use something like:

Properties props = new Properties();
InputStream is = this.getClass().getResourceAsStream("/file.properties");
props.load(is);
CrazyCoder
  • 371,688
  • 155
  • 943
  • 850