eclipse - My java application does not read my files (maven project) -


i have application in java simple project. however, need paste project maven project. so, made simple maven project, , copied , pasted classes it. need war run in server, , need run main java application, because application configures war application. however, when run main, errors wasn't having before:

java.io.filenotfoundexception: resources\config.properties (the system cannot find path specified)

when in code is:

input = new fileinputstream("resources/config.properties"); 

this didn't work either:

facedetector = new cascadeclassifierdetector("d:/retinoblastoma/workspace/resources/cascadeclassifiers/facedetection/haarcascade_frontalface_alt.xml"); 

how can fix this?

if you're using "simple maven project", maven way there src/main/resources folder. did configure pom.xml different that?

if you've done jar creation portion correctly, right way file that's on classpath is:

getclass().getresourceasstream("/path/to/resource.ext"); 

the leading forward slash important!

if file not on classpath (in other words, case if above doesn't work), need configure maven use different resources directory.

you like this (change arguments appropriate):

<build>   ...   <resources>     <resource>       <targetpath>meta-inf/plexus</targetpath>       <filtering>false</filtering>       <directory>${basedir}/src/main/plexus</directory>       <includes>         <include>configuration.xml</include>       </includes>       <excludes>         <exclude>**/*.properties</exclude>       </excludes>     </resource>   </resources>   <testresources>     ...   </testresources>   ... </build> 

then, file on classpath , above code work. read linked documentation above more information.


Comments

Popular posts from this blog

php - Zend Framework / Skeleton-Application / Composer install issue -

c# - Better 64-bit byte array hash -

python - PyCharm Type error Message -