JNLP 文件的本地替代方案?
尽我所能,我无法让 JNLP 文件在本地运行(通过双击)。这似乎是一个定位 jar 文件的问题,即使我相对于 jnlp 文件指定它也是如此。我收到以下错误:
字段
href 无效 值:helloworld.jar
即使 JNLP 文件与 helloworld.jar 位于同一文件夹中,也会发生这种情况。我已经进行了搜索,这是一个一致的问题,特别是对于那些想要将应用程序打包在 CD 上并使用 JNLP 的人来说。 Sun 提供的唯一“解决方案”是通过命令行指定代码库的能力,但这并没有多大帮助。我不明白为什么他们不假设或允许代码库是“。”或“文件://”。 - 我在 jnlp 标签的代码库参数(文件内)中尝试了这些东西,但没有任何效果。
使用 JNLP 文件对我来说非常方便,因为我不需要担心平台检测、本机库,甚至主要的 JOGL jar 文件;我只是简单地添加了这一行,一切都为我完成了:
<extension name="JOGL" href="http://download.java.net/media/jogl/builds/archive/jsr-231-2.0-beta10/webstart/jogl-all-awt.jnlp" />
我希望找到可以做同样事情的东西。如果没有,我可以手动(或使用 Ant)获取 JOGL jar 文件,这没什么大不了的;这只是 JNLP 为我做的事情之一,我真的会怀念它。
JNLP 文件的最佳替代品是什么,可供我在本地使用(即双击运行)?有什么如此优雅的东西,还是我只需要为 Linux 编写一个 shell 脚本,为 Windows 编写一个批处理文件,然后让 Ant 检测并下载适当的 JOGL jar?
Try as I might, I can't get a JNLP file to run locally (via a double-click). It seems to be an issue of locating a jar file, even when I specify it relative to the jnlp file. I get the following error:
The field <jar>href has an invalid
value: helloworld.jar
This happens even when the JNLP file is in the same folder as helloworld.jar. I've done searches and this is a consistent problem especially for people who want to package an application on a CD and use JNLP. The only Sun-provided "solution" is the ability to specify the codebase via command line, but that doesn't really help much. I don't understand why they don't assume or allow the codebase to be "." or "file://." - I tried these sorts of things in the codebase parameter of the jnlp tag (inside the file) and nothing worked.
It is extremely convenient for me to use a JNLP file because I don't need to worry about platform detection, native libraries, or even the main JOGL jar files; I simply include this line and everything is done for me:
<extension name="JOGL" href="http://download.java.net/media/jogl/builds/archive/jsr-231-2.0-beta10/webstart/jogl-all-awt.jnlp" />
I'm hoping to find something that can do the same sort of thing. If not, I can manually (or with Ant) grab the JOGL jar files, it's not a big deal; just one of those things that JNLP does for me and I'm really going to miss.
What is the best alternative to JNLP files, for me to use locally (i.e. double-click to run)? Is there anything so elegant or do I just need to write a shell script for Linux, a batch file for Windows, and have Ant detect and download the appropriate JOGL jars?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我使用了这样的 .jnlp 文件在本地启动 Java Web Start 软件
指定代码库,如下所示:
列出资源相对路径:
...
最后告诉 Web Start 在哪里可以找到标有
main="true"
的 jar 内的软件入口点:远程部署时唯一需要更改的是代码库参数。
I've used a .jnlp file like this to launch Java Web Start software locally
specify the code base like so:
<jnlp spec="1.0+" codebase="file://localhost/X:/path/to/jnlp/" href="software.jnlp">
list resources with relative paths:
<resources>
<jar href="lib/software.jar" main="true" />
<jar href="lib/softwareLibrary.jar" main="true" />
...
</resources>
and finally tell Web Start where it can find the software entry point inside the jar marked with
main="true"
:<application-desc main-class="com.example.Main" />
The only thing you need to change when deploying remotely is the codebase parameter.
只需从
jnlp
标记中删除属性codebase
和href
即可。从 java 1.6u18 开始支持这一点。
Just remove the attributes
codebase
andhref
fromjnlp
tag.This is supported since java 1.6u18.
JNLP 系统通过 Java 6 update 10(不久前)进行了改进,但它仍然很难调试(在 Java 控制台中启用完整跟踪,并逐步执行 javaws 源代码)。
在您的情况下,我会加倍努力,也许您会提供一个完整的 JNLP 文件来显示问题?
The JNLP system was improved with Java 6 update 10 (a while back) but it is still quite hard to debug (enabling full tracing in the Java Console, and stepping through the javaws source code.
In your situation I would go the extra mile and get it to work. Perhaps you would provide a full JNLP-file showing the problem?
使用你的 jar 的清单。在那里您可以定义要启动的主类和所需的库。请参阅清单规范中的 Main-class 和 Class-path 参数。
Use a manifest for your jar. There you can define the main class to start and the required libraries. See the Main-class and Class-path arguments in the manifest specification.
JNLP 是为网络启动(特别是 http(s))而设计的,如果没有网络,Java 实现一定会变得非常混乱。即使像 eclipse 这样的成熟项目也坚持使用 .sh、.bat 选项。
JNLP is designed for network launching (specifically http(s)) and without a network the Java implementation must get really confused. Even mature projects like eclipse stick with the .sh,.bat option.