vendredi 22 janvier 2016

How to set relative path for a folder in Maven java web application?

I am creating a Maven web application which stores many policy files in policy folder. My source folder layout looks like : enter image description here I tried to set the folder path as policyLocation as shown below:

try {
                        // InputStream aa =
                        // Accesscontrol.class.getClass().getResource(aa);
                        String AbsolutePath = new File("/").getAbsolutePath();
                        String policyLocation = (new File("."))
                                .getCanonicalPath() + File.separator + "policy";
                        System.setProperty(
                                FileBasedPolicyFinderModule.POLICY_DIR_PROPERTY,
                                policyLocation);
                    } catch (IOException e) {
                        System.err.println("Can not locate policy repository");
                    }

But this is returning my Eclipse folder. Is there anyway I can get the policy folder that is not inside Resource folder (cause it can't be included inside Resource) in java web application?




Aucun commentaire:

Enregistrer un commentaire