This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Sockets and Internet Protocols and the fly likes ftp and threads problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "ftp and threads problem" Watch "ftp and threads problem" New topic
Author

ftp and threads problem

angel sar
Greenhorn

Joined: Aug 29, 2009
Posts: 17
Hello. I have to solve a requirement and i need some guides. The issue is that my program needs to send a file through ftp every 2 hours. For this issue i have some questions hope you can help me.
1) for the ftp sent, i ve found 2 solutions. Use commons net or jftp from sourceforge page. Whay do you recommend? maybe other?
2)to do something very some time, i thought to program a thread but i ve heard that other good way to do this is by using javax.swing.Timer and java.util.Timer. What do you recommend? Maybe a java daemon library?

Just in case, this program will run in a war file on a was.

Thank you for your time and response.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19655
    
  18

angel sar wrote:1) for the ftp sent, i ve found 2 solutions. Use commons net or jftp from sourceforge page. Whay do you recommend? maybe other?

I haven't used Commons Net, and I've never even heard of jftp. However, Commons Net has a large fan base and has proven itself over the years. I myself however prefer JvFTP, also on SourceForge. I just prefer its treatment of remote files using the FtpFile class.

2)to do something very some time, i thought to program a thread but i ve heard that other good way to do this is by using javax.swing.Timer and java.util.Timer. What do you recommend? Maybe a java daemon library?

javax.swing.Timer is probably a bad idea. It will run on the Event Dispatcher Thread, so your entire FTP upload will hang your GUI until finished. java.util.Timer is an option, but these days I prefer a ScheduledExecutorService.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
angel sar
Greenhorn

Joined: Aug 29, 2009
Posts: 17
Thak you for your answer. Can you give me more details about implementing ScheduledExecutorService?

Thanks
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19655
    
  18

java.util.concurrent.ScheduledExecutorService
The class Javadoc has a nice little example. You can use the ScheduledFuture's that are returned to cancel the jobs.
angel sar
Greenhorn

Joined: Aug 29, 2009
Posts: 17
thanks again. I forgot to tell you a little detail. I have to use jdk 1.4 because of
my server version, . In this scenario, what do you recommend?
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19655
    
  18

Either java.util.Timer or Quartz.
angel sar
Greenhorn

Joined: Aug 29, 2009
Posts: 17
Im getting all i need to start to program thank you. But i have i new question.
what free ftp server dou you recommned to test and use my program?
I ve heard about filezilla and apache ftp server.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19655
    
  18

I have good experience with FileZilla for Windows and ProFTPd for Linux.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: ftp and threads problem
 
Similar Threads
configure tomcat server
include jar in an executable jar
Restart TOMCAT is required if server time is changed?
File download from Unix server with password
File transferring