I have a properties file located in C:/codebase/myProject-Authentication/sample.properties
, and my workspace is at C:/codebase/myProject/com.company.team.website/src/.../AccessCodeServlet.java
.
So, I need to read sample.properties
from AccessCodeServlet.java
. AccessCodeServlet
is a servlet.
If the properties file is in the same folder as AccessCodeServlet.java
, I can just do this:
ResourceBundle bundle = ResourceBundle.getBundle("sample");
But how do I do it when properties file is outside workspace?
Well, you can add an external folder containing your sample.properties to the classpath in eclipse:
Viola - now resource bundles are found!