Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ftp and threads problem

 
angel sar
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20495
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
angel sar
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thak you for your answer. Can you give me more details about implementing ScheduledExecutorService?

Thanks
 
Rob Spoor
Sheriff
Pie
Posts: 20495
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20495
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Either java.util.Timer or Quartz.
 
angel sar
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20495
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have good experience with FileZilla for Windows and ProFTPd for Linux.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic