0

I´ve included a jar (I built it: MyJar.jar) that i use to authenticate, in that jar I have to read some properties that I have in a package (e.g com.myproject.properties) inside a property file of my project.

I have a method in MyJar.jar which receive the name of the property and the path for the property file something like this:

public String getValueOfProperty(String property,String pathToPropertyFile){

    BasicTextEncryptor encryptor = new BasicTextEncryptor();
         Properties props = new EncryptableProperties(encryptor);
         props.load(new FileInputStream(pathToPropertyFile));
         ....
}

I got the following error: System can't find the specified path

The path is: com/myproject/properties/conf.properties

What am I doing wrong?

DuSant
  • 970
  • 12
  • 25

1 Answers1

0

Solved,

This is what i Used:

The path the method receives is something like this: /sv/com/myproject/configuration/file.properties,

This method will search with relative path

 public String decryptVar(String var,String PathPropertyFile) throws Exception{

    try {
         BasicTextEncryptor encryptor = new BasicTextEncryptor();
         Properties props = new EncryptableProperties(encryptor);
         InputStream fis = this.getClass().getResourceAsStream(PathPropertyFile);
         props.load(fis);
         encryptor.setPassword(props.getProperty("PROPERTY_IN_FILE")); 
         return props.getProperty(var);

    } catch (Exception e) {
    throw new Exception(e.getMessage());
    }   

}

Implementing: JASYPTH

DuSant
  • 970
  • 12
  • 25