File Listener Implementation using Java

I'm trying to use  FileAlterationListener, FileAlterationObserver from Apache Commons IO to listen to Files.
How do i make the  program start automatically without using "main" so that File Monitor starts once the bean is deployed on to JEE server.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Can you not create an implementation of ServletContextListener? which will simply start your File Monitor.
prashant_eeAuthor Commented:
Thanks for your Quick Reply gurpsbassi.
Do i need to deploy the packaged application as WAR?
Yes, configure the listener in the web.xml or if you're using the servlet 3.0 spec then you can simply just annotate your listener class with @WebServletContextListener
10 Tips to Protect Your Business from Ransomware

Did you know that ransomware is the most widespread, destructive malware in the world today? It accounts for 39% of all security breaches, with ransomware gangsters projected to make $11.5B in profits from online extortion by 2019.

Also when you say
once the bean is deployed on to JEE server
, are you implying this is a EJB?
prashant_eeAuthor Commented:
Yes, I was looking into EJB as one of the option packaged as EAR. Runtime environment is Websphere 8.0
You could also use a timer service for the EJB;

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Bear in mind too that the JRE has supported file watching out of the box since 1.7
prashant_eeAuthor Commented:
@CEHI..Thanks for your Reply..
I would love to use 1.7 , but unfortunately Websphere 8.0 supports 1.6
prashant_eeAuthor Commented:
Straight forward solution for what i was looking for..Thank you!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.