Home arrow static arrow Java Programming [Archive] - Clock
Warning: Creating default object from empty value in /www/htdocs/w008deb8/wiki/components/com_staticxt/staticxt.php on line 51
Java Programming [Archive] - Clock
This topic has 7 replies on 1 page.

Posts:3
Registered: 7/22/04
Clock  
Jul 22, 2004 7:34 AM



 
Hi,
I'm italian so I'm sorry for my language.
I have a problem that I can't solve: I have a program and I want that it starts automatically once an hour (for example at 1 o clock,2 o clok.....),so I tought I need something similar to a clock....please,can you help me???
Thank you all Filippo
 

Posts:342
Registered: 5/22/98
Re: Clock  
Jul 22, 2004 7:52 AM (reply 1 of 7)



 
Do you want to start your program automatically, every hour, or do you want your program to do something once per hour and sleep between?
 

Posts:27
Registered: 8/21/03
Re: Clock  
Jul 22, 2004 8:22 AM (reply 2 of 7)



 
To do this you can implement a thread ....

thread.sleep(60*60*1000) // this will cause to sleep for one hour

or if you are not sure that how long a process will take to perform ... then you can make thread sleep for one minute and check time after every minute.

I hope this will help you.

 

Posts:3
Registered: 7/22/04
Re: Clock  
Jul 22, 2004 9:18 AM (reply 3 of 7)



 
I want that my program does something once per hour and sleep between.
for adams2000:thanks for the code you write me....but I have a question:what are the import at the beginning of the program?
 

Posts:316
Registered: 4/7/04
Re: Clock  
Jul 22, 2004 9:23 AM (reply 4 of 7)



 
I want that my program does something once per hour
and sleep between.
for adams2000:thanks for the code you write me....but
I have a question:what are the import at the beginning
of the program?

Use the [url=http://java.sun.com/j2se/1.5.0/docs/api/index.html]API[/url]
[url=http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Thread.html]java.lang.Thread[/url]

Also look into [url=http://java.sun.com/j2se/1.5.0/docs/api/java/util/Timer.html]Util Timer[/url] and [url=http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/Timer.html]Swing Timer[/url]
 

Posts:3
Registered: 7/22/04
Re: Clock  
Jul 22, 2004 9:33 AM (reply 5 of 7)



 
ok,the program works very well.....thanks for your collaboration!!!!
Now I have another question(the last),how can I get a .exe file from a .class file?
I have yet look for in the forum,and someone says to write javaw -cp [dir of program] [main class of program] but it doesn't work....
Filippo
 

Posts:316
Registered: 4/7/04
Re: Clock  
Jul 22, 2004 9:52 AM (reply 6 of 7)



 
ok,the program works very well.....thanks for your
collaboration!!!!
Now I have another question(the last),how can I get a
.exe file from a .class file?
I have yet look for in the forum,and someone says to
write javaw -cp [dir of program] [main class of
program] but it doesn't work....
Filippo

java [-options] class [args...]
java [-options] -jar jarfile [args...]

where options include:
-cp <class search path of directories and zip/jar files>-classpath <class search path of directories and zip/jar files>              A ; separated list of directories, JAR archives,              and ZIP archives to search for class files.

eg:
java -cp classes;lib/MyProgram.jar com.mydomain.MyMainClass
 

Posts:27
Registered: 8/21/03
Re: Clock  
Jul 23, 2004 12:11 AM (reply 7 of 7)



 
To make exe there are several options ....

1. You can make a jar file. when making jar file in menifest file you can specify the main class as well as the classpat

2. You can use as it was mentioned in previous posting.

3. You can set the classpath in autoexec.bat Win95 or in the system veriable CLASSPATH if it does not exits create one. then you dont need to tape each time classpath. you can simple call

javaw main prg

4. Using some external tools like InstallShield/InstallAnywhere/NSIS you can make a exe or a installation like any other programs. I will prefer InstallAnywhere becuase then you can deploy application across serveral platforms.

I hope this will help you :)

 
This topic has 7 replies on 1 page.