Skip to content

Instantly share code, notes, and snippets.

@jijeshvu07
Last active July 30, 2018 11:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jijeshvu07/0600e4e487741a1401b5e049cc2af6e1 to your computer and use it in GitHub Desktop.
Save jijeshvu07/0600e4e487741a1401b5e049cc2af6e1 to your computer and use it in GitHub Desktop.
Read .properties from a jar
private InputStream readProperties() throws IOException {
File jarPath = new File(Main.class.getProtectionDomain().getCodeSource().getLocation().getPath());
JarFile jarFile = new JarFile(jarPath);
JarEntry entry = jarFile.getJarEntry("PROPERTY_NAME");
InputStream input = jarFile.getInputStream(entry);
return input;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment