/** * @author user1 * * To change this generated comment edit the template variable "typecomment": * Window>Preferences>Java>Templates. * To enable and disable the creation of type comments go to * Window>Preferences>Java>Code Generation. */ class MainApplication {
public static void main(String[] args) { Timer timer = new Timer(); Calendar date = Calendar.getInstance(); // date.set( Calendar.DAY_OF_WEEK,Calendar.SUNDAY); date.set(Calendar.HOUR, 17); date.set(Calendar.MINUTE, 12); date.set(Calendar.SECOND, 0); date.set(Calendar.MILLISECOND, 0); // Schedule to run every Sunday in midnight ReportGenerator obj = new ReportGenerator(); timer.schedule(obj,date.getTime(),1000); } }
C:\amit\amit\org>java MainApplication Exception in thread "main" java.lang.NoClassDefFoundError: MainApplication (wron g name: org/MainApplication) at java.lang.ClassLoader.defineClass0(Native Method) at java.lang.ClassLoader.defineClass(Unknown Source) at java.security.SecureClassLoader.defineClass(Unknown Source) at java.net.URLClassLoader.defineClass(Unknown Source) at java.net.URLClassLoader.access$100(Unknown Source) at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClassInternal(Unknown Source)
C:\amit\amit\org>
===================================
Y THIS ERROR IS COMMING ???
can anybody guide me please..... how to succesfully run the progrom..
this is a classpath problem. The JRE can not find your main class. The fully qualified name of your MainApplication class is org.MainApplication. So you need to execute the command
C:\amit\amit\>java org.MainApplication instead of C:\amit\amit\org>java MainApplication
this should work.
there is also the -classpath (or -cp for short)flag you can pass to the JRE: C:\projects\something>java -cp build org.something.App (like this you specify that your org.something.App class is located in the build directory)
i hope this works for you now.
pascal
amit taneja
Ranch Hand
Joined: Mar 14, 2003
Posts: 806
posted
0
thanx
ya pascal it runs
but nothing is happening in output.... it must print the result "Generating Report" after every one second from the time specified .. but no out put is comming
the code is the same as above..i posted... kindly try this.... and run this..... ( do me this favor )
i m developing the sheduler....
thanx and regards, amit
pascal betz
Ranch Hand
Joined: Jun 19, 2001
Posts: 547
posted
0
add this line
to see when the Task will be executed the first time...
just remove the date.setXXX() methods (or use a different Timer.schedule() method) and it will start right now.
pascal
Jef Cumps
cowbird
Ranch Hand
Joined: Nov 14, 2001
Posts: 53
posted
0
Hi,
I tried your little prgram, and it works fine with me.. after I changed the hour set in your date member to an hour in the past. Try it first without all setters on your date, just pass the newInstance() to the timer. That will work. Then start experimenting with the setters on your date, watch out for AM and PM mistakes! (check the calendar-API)
oK THANX every thing is working now...but now this i have to implement in servlet but there is problem .....
i cannot create my servlet object to be passed in sheduler obj= new sheduler(); // above i created the instance of servlet...in which i have writen //sendRedirect() function... now how to call the servlet using // timer.sheduler(); timer.shedule(obj.date.getTime(),1000);
Ok can any body tell me how to call a webpage from a class that is not servlet ...is it possible ?? actually i m developing a servlet which will be invoked at particular time and redirect page to some else page...
so should i use threads in servlets ? can we use that ? but how.. i mean .... we should pass the object as an argument to Thread class.. can that object be servelt object ???
pls reply
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.