Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Properties file location #5

Closed
saprophagist opened this issue Aug 14, 2020 · 3 comments · Fixed by #8
Closed

Properties file location #5

saprophagist opened this issue Aug 14, 2020 · 3 comments · Fixed by #8
Labels
good first issue Good for newcomers type: bug Something isn't working
Milestone

Comments

@saprophagist
Copy link

Describe the bug
If developing out of maven and project structure is not "/src/main/resources/.." properties file can't be found. Also can't set path manually.

To Reproduce
Develop a simple application with Netbeans (Ant build) and try to run.

Expected behavior
Load properties as defined in properties file.

Environment:

  • OS: Windows 10
  • JDK OpenJDK 11.0.2
  • Version 1.3.1

Additional context
Project structure:

  • project root
    |
    • resources (x/y/z/abc.properties)
      |
    • src (...)
      |
    • test
      (etc.)
@saprophagist saprophagist added the type: bug Something isn't working label Aug 14, 2020
@firaja firaja added the good first issue Good for newcomers label Aug 28, 2020
@firaja firaja added this to the 1.3.2 milestone Aug 28, 2020
@firaja
Copy link
Member

firaja commented Aug 28, 2020

Hi @saprophagist,
thanks for opening this issue.

I think it may be useful if the user specifies with a custom Java property the path of the property file.
E.g. users run the application like java -Dpsw4jPropertiesPath=x/y/z/abc.properties ...

firaja added a commit that referenced this issue Sep 9, 2020
firaja added a commit that referenced this issue Sep 9, 2020
@firaja firaja linked a pull request Sep 9, 2020 that will close this issue
Merged
firaja added a commit that referenced this issue Sep 9, 2020
firaja added a commit that referenced this issue Sep 9, 2020
firaja added a commit that referenced this issue Sep 9, 2020
@firaja firaja closed this as completed in #8 Sep 9, 2020
@firaja
Copy link
Member

firaja commented Sep 9, 2020

You can now set your property file with -Dpsw4j.configuration=/my/path

@realpixelcode
Copy link

@saprophagist You can also set that property dynamically in your code (so your users don't have to use the command-line argument) like this (make sure to replace MyCoolApp with your actual class name):

String configurationFileName = Objects.requireNonNull(MyCoolApp.class.getResource("psw4j.properties")).getFile();
File configurationFile = new File(configurationFileName);
System.setProperty("psw4j.configuration", configurationFile.getAbsolutePath());

This does the exact same as declaring the property via the command line. (See the PropertyReader for more info.)

@firaja I strongly suggest to add this piece of information to the project's wiki.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers type: bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants