小程序和库
我的小程序看不到外部库。一切都可以使用 appletviewer 进行,但不能使用浏览器。我已将包含 applet 类的 jar (TreC-Vis.jar)、TreC-Vis 使用的四个 jar 库以及带有以下 applet 标记的 html 文件放入“test_applet”文件夹中:
<applet code="gui.Gui" archive="TreC-Vis.jar,postgresql-8.4-701.jdbc4.jar,postgis_1.5.0.jar,jfreechart-1.0.13.jar,jcommon-1.0.16.jar" width="1024" height="768"> </applet>
Java 控制台为我提供了 java.io四个 jar 库中的每一个都出现 .FileNotFoundException。 我指定从相应的 Eclipse 项目导出 TreC-Vis.jar,其中我将这些库放在“src”包同一级别的“lib”文件夹中。
我写的小程序标签有什么问题? 阅读此处的教程
http://download.oracle.com/javase/tutorial /deployment/jar/downman.html
我一直在考虑将所有内容(小程序和库)放在一个 jar 中作为解决方案的可能性,但我需要注释中提到的“自定义代码”的一些示例。 提前致谢。
My applet doesn’t see the external libraries. Everything works using the appletviewer, but not using the browser. I’ve put in my “test_applet” folder the jar (TreC-Vis.jar) containing the applet classes, four jar libraries used by TreC-Vis and the html file with the following applet tag:
<applet code="gui.Gui" archive="TreC-Vis.jar,postgresql-8.4-701.jdbc4.jar,postgis_1.5.0.jar,jfreechart-1.0.13.jar,jcommon-1.0.16.jar" width="1024" height="768"> </applet>
Java console gives me a java.io.FileNotFoundException for each of the four jar libraries.
I specify that I exported TreC-Vis.jar from the corresponding Eclipse project, in which I put these libraries in a “lib” folder at the same level of the “src” package.
What’s wrong with the applet tag I wrote?
Reading the tutorial here
http://download.oracle.com/javase/tutorial/deployment/jar/downman.html
I’ve been considering the possibility to put everything, applet and libraries, in one jar as a solution, but I would need some example of the “custom code” mentioned in the Note.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这就是我一直在寻找的线路。这样我就将外部库的类路径放入了清单中。
This was the line I was looking for. This way I've put in my manifest the classpath of the external libraries.
这是我的代码以及我如何在其中使用本机库。它在 Windows 中可以工作,但在 Linux 中不起作用,并且我收到
访问被拒绝(“java.lang.RuntimePermission”“loadLibrary.hello”)
这是我的 JNLP:
我的 Applet:
我的本机 .c 代码:
我的 HTML 页面:
libhello.jar 包含我的本机代码的共享对象,并且与 html 和 jnlp 位于同一文件夹中。
当我将 hello.jar(包含 hello.dll)放入资源部分时,它在 Windows 中有效,但在 Linux 中我收到了上述错误。
Here is my code and how I have used native libraries in that. It does work in Windowes but it doesn't work in Linux and I receive
access denied("java.lang.RuntimePermission""loadLibrary.hello")
Here is my JNLP:
My Applet:
My native .c code :
My HTML page:
libhello.jar contains the shared object of my native code and is located on the same folder as html and jnlp.
It works in windows when I put hello.jar(containing hello.dll) in resource section but in Linux I received the mentioned error.
好吧。如果那么,您的意思是 .dll、.so 等类型的文件中的“本机”,这对于小程序来说是有问题的,因为它们无法使用本机,除非它们已经安装在用户系统的适当目录中。
话虽如此,最近的发展允许我们使用 Java webstart (JWS) 部署嵌入式小程序。 JWS 使本地人的使用变得容易。只需将它们放在 Jar 文件的根目录中,然后将它们添加到(基于 XML 的)启动文件(文件类型 .jnlp)中的 nativelib 元素即可。
更好的是,JWS 可以将下载分成不同操作系统的资源,因此 Windows 获得 .dll 本机,而 *nix 获得 .so 本机。
JWS 提供了许多更有用的功能,但这里重要的是它们可以使本机可用于小程序。
在小程序中使用本机库需要信任该小程序。
OK. If then, you mean 'natives' as in files of type .dll, .so etc., that is problematic for an applet in that they cannot use the natives unless they are already installed in the appropriate directory of the user system.
Having said that, recent developments allow us to deploy an embedded applet using Java webstart (JWS). JWS makes use of natives easy. Simply put them in the root of a Jar file and add them to a nativelib element in the (XML based) launch file (file type .jnlp).
Even better, JWS can separate the downloads into resources for different operating systems, so Windows gets the .dll natives, while *nix get the .so natives.
JWS offers many more useful features, but the important thing here is that they can make natives available to applets.
Use of native libs in an applet, requires the applet to be trusted.