• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

scheduler task

 
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i need write the task to be schedule using window scheduler. How do i write the task? using servlet? or just a normal java method?

im using struts framework.
 
Ranch Hand
Posts: 884
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It depends on the nature of your task. Since you're using Struts, must it be web-based? Or can you make do with a simple Java class? If a simple Java class suffice, then it would be simple, as per how you normally configure the scheduler.
 
lynn fann
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i will be writing it as a standalone java application. But i dont know to start writing the function. Just as like normal, java class with void main? I have not done scheduler before. thanks
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If it is standalone application then you won't be able to use Struts or servlets.

But I'm not sure what you mean by "Windows scheduler". Java has its own scheduling system (based on java.util.Timer and TimerTask), but that is independent of any scheduling that happens within Windows. And it is active only as long as the JVM is active, so if you base this on an application, then that application will need to keep running permanently.
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think you can use Windows Task Scheduler to kick off any program. You could have it run "java MyProgram ..." but you probably want more control over paths and classpaths and such, so you could have Scheduler kick off a bat file that sets those variables and then runs "java MyProgram ..." And, yes, MyProgram would start in main() just like any other Java program.
 
lynn fann
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi Stan James,

have another doubt hope you can help me to clarify. for the codes, i need to link to database to update some records, is it that i just as per normal have all those connection statement in the method? For those connection statement, can i call from other files?

In the bat file, i need to set the classpath all those. for the classpath it has to be a full path like, C:\work\lib\lib.jar? Can i do it like C:\work\lib\*.jar?

where should i place the bat file? same place as the class file?

thanks.

I tried:
set CLASSPATH=C:\j2sdk1.4.2\bin;C:\Documents and Settings\informix\Desktop\iadv\build\web\WEB-INF\lib\*.jar;
set PATH=C:\Documents and Settings\informix\Desktop\iadv\build\web\WEB-INF\classes\com\job;

java EnquiryScheduleTask

but i got this error:
Exception in thread "main" java.lang.NoClassDefFoundError: EnquiryScheduleTask (
wrong name: com/job/EnquiryScheduleTask)
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:537)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:251)
at java.net.URLClassLoader.access$100(URLClassLoader.java:55)
at java.net.URLClassLoader$1.run(URLClassLoader.java:194)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)
at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
}
[ May 14, 2007: Message edited by: lynn fann ]
[ May 14, 2007: Message edited by: lynn fann ]
 
Is that a spider in your hair? Here, threaten it with this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic