I've written a java program which copy all the connected drives data by a specified extension and it works fine. but the problem is that scenario happens only once.
Then I have to run the program manually again.
How could i make the program runs in the background and listen to all the USB ports in a real time manner and persist when restarting the OS, so once a USB drive is plugged into the PC the program will start copying its data.
I think if it could be run as a Windows Service that might work?
Any thoughts would be appreciated.
解决方案
Refer - Java program running in background[^]
Quote:
Follow the these steps to do the job :(Assuming you are using windows and jre is installed )First compile your java program and place the class file at one location.
Now create a bat file and place java LOCATION TO THAT CLASS FILE/MyProgram in that.
Put your bat file in start up programs
Restart the system, you will get your program running in back ground..!
Hope this will help you.