如何让java程序在后台运行? [英] How do I make a java program runs in the background ?

查看:942
本文介绍了如何让java程序在后台运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了一个java程序,它通过指定的扩展名复制所有连接的驱动器数据,并且工作正常。但问题是场景只发生一次。

然后我必须再次手动运行程序。



我怎样才能制作程序在后台运行并以实时方式收听所有USB端口并在重新启动操作系统时保持不变,因此一旦USB驱动器插入PC,程序将开始复制其数据。



我认为它是否可以作为可以运行的Windows服务运行?



任何想法都会受到赞赏。

解决方案

请参阅 - 在后台运行的Java程序 [ ^ ]

引用:

按照以下步骤完成工作:(假设你正在使用windows和jre安装)



  • 首先编译你的java程序并将类文件放在一个位置。
  • 现在创建一个bat文件并在其中放置 java LOCATION TO THAT CLASS FILE / MyProgram
  • 将你的bat文件放入启动程序
  • 重新启动系统,你将让你的程序在后台运行..!

    希望这对你有帮助。


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.


这篇关于如何让java程序在后台运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆