在Windows启动时自动启动Java应用程序的代码 [英] Code for Auto starting a java application on windows startup

查看:218
本文介绍了在Windows启动时自动启动Java应用程序的代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

java桌面应用程序的自动启动?

I有一个使用netbeans 6.5.1的Java桌面应用程序。我想知道是否有人可以帮我建议在Windows启动时自动调整Jar文件的代码。

I have a Java desktop application using netbeans 6.5.1. I was wondering if anybody can help me in suggesting code for autosatrting the Jar file on windows start up.

提前感谢
Bhavi

Thanks in advance Bhavi

推荐答案

这取决于Windows Startup的含义。在没有用户登录的情况下在后台运行它,您必须创建一个Windows服务包装器。

It depends on what you mean by "Windows Startup". Running it in the background without a user logging in, you'd have to create a Windows Service wrapper.

如果Windows启动意味着在用户登录时运行在,创建一个批处理文件,启动您的应用程序并将该批处理文件的链接放入用户的Autostart文件夹(或所有用户自动启动文件夹)。

In case "Windows Startup" means "run when the user logs in", create a batch file that starts your application and put a link to that batch file into the user's Autostart folder (or the "All Users" Autostart folder).

编辑
根据您的意见澄清我的意思。

EDIT To clarify what I mean according to your comments.

您说您是.NET程序员,所以我们可以像开发.NET应用程序一样说话:

You said you were a .NET programmer, so we can just talk like you'd develop a .NET application:


  1. 如果您的程序应该像Windows服务一样,那么您需要某种服务包装器充当真正的Windows服务,并在使用服务管理器启动时启动程序(到目前为止,您无法使用Java开发Windows服务,因此需要此包装器。)

  1. If your program should behave like a Windows Service, you'd need some kind of service wrapper that acts as the "real" Windows service and starts your program when it is started using the Service Manager (you can not develop a Windows Service in Java so far, so you need this wrapper).

如果您的程序应该像普通应用程序一样运行,只需在用户登录时启动(例如le:Skype或WinAmp Agent),您只需启动程序就可以将链接添加到用户的AutoStart文件夹中。

If your program should behave like a normal application and just be started whenever a user logs on (example: Skype or WinAmp Agent), you'll just have to start your program putting a link to it into the user's AutoStart folder.

如果是1),你必须按照其他海报的答案 - 我以前从未做过这个,但我相信它可以做到。 (也许这个链接可以帮到你: http://edn.embarcadero.com/article/32068

In case of 1), you'd have to follow the answers of the other posters - I've never done that myself before, but I'm sure it can be done. (Maybe this link will help you: http://edn.embarcadero.com/article/32068)

如果是1),只需创建一个运行应用程序的批处理文件,并在用户的/所有用户的AutoRun文件夹中创建指向该批处理文件的链接。

In case of 1), just create a batch file that runs your application and create a link to that batch file in the user's/All Users' AutoRun folder.

这篇关于在Windows启动时自动启动Java应用程序的代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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