I have one plain .java class. In that class I’m using a Timer class schedule method, to schedule a task.
The problem is I’m using a Java EE application, and I dont know where to intantiate this class; from a Servlet or any thing like that? I want to instantiate that class only once when my application goes up.
You probably need a
ServletContextListenerand its methodcontextInitialized(..). It is invoked once, when your application is initialized.You map the listener with either
@WebListeneror with<listener><listener-class>..</...>in web.xml