by the way - this does not "encrypt" anything... (as noted in his comments).
Quote:
after obtaining it from some encrypted source.
It is a way to pass the password, without it being hard coded into the conf file. You still have to setup the password as a command line option by defining a system property (with -Dprop=passwrd) or by loading some properties file (just as secure as the original problem of having it in a hib config file). Then if you use -D on command line it is available to the process table, where everyone on that machine (in unix & perhaps windows) can read the password in plain text.
The easy way to ensure that it is properly encrypted is through JNDI and Datasource.
If you were to use the System.property way, as a complete recommendation for using -D would be to explain how an ecrypted password would get to your program (again available plain-text).
In this light - One way to accomplish this is to encrypt a properties file and then decrypt the entire file in your program startup, and load the property and setup that one property in the system properties. Obviously, you'd have to roll your own encrypt/decrypt of the file and load/set property.
There are lots of other ways.. since all you really need to do is to get the plain text into your program, via streams..etc. and then setup your property with System.setProperty(...);
(I edited my answer).