Java Web Start 和主类
我做了一个应用程序,一开始就会自动更新。在 stackoverflow 上阅读时,很多人建议使用 Java web start。 因此,通过 Netbeans,我启用了 Web 启动配置等等。它生成了 launch.jnpl html 、 jar 文件和 lib 文件夹。 在程序的主部分中,我插入了
DownloadService2 service = (DownloadService2)
ServiceManager.lookup("javax.jnlp.DownloadService2");
ResourceSpec spec = new ResourceSpec("http://www.mysite:8080/.*", "1.*", service.JAR);
ResourceSpec results[] = service.getCachedResources(spec);
results = service.getUpdateAvailableResources(spec);
SO,我将 dist 文件夹中的所有文件上传到网络服务器。现在,如果我使用 Lunch.jnpl 启动应用程序,它将毫无问题地启动。但是当我使用我的 jar 文件时,出现错误:找不到主类“我的类”程序退出。
现在,如果我不使用 DownloadService2,它可以与 Jar 文件一起使用。 所以我的问题是: 我如何使用 Java Web start 更新我的程序?
例如,如果我发布另一个版本并放入代码库 url,如果我使用 jar 文件启动程序,它应该下载新版本。
有人可以告诉我我是否做错了什么或误解了 Java Web Start 的工作原理吗?
编辑:我希望程序遵循这一行: 1)如果可能的话,与罐子共进午餐,检查更新...如果因为离线而无法使用旧的 2) 如果在线检查更新是否可以在文件夹中下载更新 3) 如果更新不可用,请使用旧版本。 重复 1 2 3
I made an application and i would have an auto-update at start. Reading on stackoverflow many people suggest Java web start.
So with Netbeans i enabled web start configuration and soon on. It generated launch.jnpl html , jar file and lib folder.
In the main of program i insert
DownloadService2 service = (DownloadService2)
ServiceManager.lookup("javax.jnlp.DownloadService2");
ResourceSpec spec = new ResourceSpec("http://www.mysite:8080/.*", "1.*", service.JAR);
ResourceSpec results[] = service.getCachedResources(spec);
results = service.getUpdateAvailableResources(spec);
SO i uploaded all files in dist folder to webserver. Now if i start the application with lunch.jnpl it starts without problem. But when i use my jar file i got error : Could not find main class "My class" program exit.
Now if i dont use DownloadService2 it works with Jar File.
So my question is :
How could i use Java Web start to Update my program?
For example if i release another version and put it codebase url, if i start program with jar file it should downloads new version.
Could someone tell my if i wrong something or misunderstood how Java web start works ?
Edit: i would that programs follows this line :
1) lunch with jar if it's possibile , Check for update...if it cant becouse offline use the old ones
2) if online check for update if aviable download update in the folder
3) if update not aviable use older one.
repeat 1 2 3
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,现在是两个人了,不是吗:
首先,为什么你会收到有关主类的错误?您的 jnlp 文件是否具有声明的主类的正确包和名称?应该是这样的:
其次,更新是如何进行的。一旦有人访问您的 jnlp 文件并从中启动您的 jar 应用程序,该 jar 就会下载到客户端计算机上的本地。然后,当他第二次运行它时,jnlp协议将首先检查url以查看jar是否已更新。如果是这样,那么它将获得新版本,这就是客户端将运行的版本。如果尚未更新,先前下载的 jar 将从本地计算机运行。
Well this is a two parter now, isn't it:
First, why do you get an error about your main class? Does your jnlp file have the correct package and name of the main class declared? It should be something like:
Secondly, how does the update work. Well once someone accesses your jnlp file and starts your jar application from it, that jar is downloaded locally on the client's machine. Then, when he runs it a second time, the jnlp protocol will first check the url to see if the jar has been update. If so, then it gets that new version and that's what the client will run. If it hasn't been updated the previouslly downloaded jar will be run from local machine.