Hi. I really need help.
I´ve written a program in java that connects to an ftp-server and changes files.
as it is now i have a JPanel and i have to press a button and write the name of the file
but i want the program to do this automatically when a new file comes to the server. can anyone
help me?

sorry man I know u are writing in English but you are going to have to be more descriptive as you are not really making sense

ok. Hm hardly know myself what i want. =)
Like i said i made a program with a GUI and JButtons, in java. So after i connected to the server i press one button and then my program downloads a file from the server and makes some changes with the file and uploads it again. But the company that i´m doing this for, it´s a schoolproject, don´t want to write which file the program should download and they don´t want to have to press the button every time. They recieve files to their server daily and they want the program to run on its own and download files from the server every time there is a new file.
Better explenation?

You may want to look at the observer design pattern.

There are at least 2 ways to approach this. I can tell you from a desing perspective but my java specifics may lack. At any rate, method one requires that you need some server side code that can fire an event whenever a file is loaded. that event will trigger the frp process on your side.

Method 2 is more stable, eaiser to implement but not as efficient. If your client (the one your'e writing the code on - transferring the file to) is a Linux / Unix type, then you will have a crontab utility. There you can specify a time and frequency to fire a specific "job" in this case, some code that you've written to poll a server for a file and transfer. You mentioned that the file is dropped daily, that you have an approximate time window which to expect it so you should have all you need. Here is a good resource on crontab:

http://www.adminschoice.com/docs/crontab.htm

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.