Eclipse 中具有依赖项的 Applet
一般来说,我对 eclipse 和 java 相当陌生,所以我确信这是非常基本的,但我找不到任何能指引我正确方向的东西。
如何在 Eclipse 中运行/测试需要一些第 3 方 jar 的小程序?
我有一个应用程序与我的依赖 jar(具体来说是 JOGL)一起运行,效果很好。我可以运行一个示例小程序。但我无法运行需要 JOGL jar 的小程序。我知道将其嵌入到网页中的 HTML 需要引用依赖项,但是由于它不是标准 java 工具包的一部分,我如何告诉 eclipse 去哪里查找呢?
我的最终需要是将应用程序/小程序嵌入网页中(不是从中启动,而是作为页面上的内联对象运行。我还没有尝试嵌入任何东西,但也许有一个角落我可以切到那里,我根本不必担心小程序结构......
I'm fairly new to eclipse and java in general, so I'm sure this is pretty basic, but I can't find anything that points me in the right direction.
How do I run/test an applet in Eclipse that requires some 3rd party jars?
I have an application running with my dependent jars (JOGL to be specific) fine. And I can run a sample applet. But I can't run an applet that requires the JOGL jars. I understand the HTML for embedding it in a web page needs to reference the dependencies, but how do I tell eclipse where to look since it's not part of the standard java kit?
My ultimate need is to embed an application/applet IN a web page (not launched from, but running as in inline object on the page. I haven't gotten as far as trying to embed anything yet, but perhaps there's a corner I can cut there and I won't have to worry about the applet structure at all...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以采用与具有 main() 方法的程序相同的方式进行操作。转到属性 -->构建路径 -->罐子。在那里添加您的第三方罐子,程序应该会拾取它们。
首先创建一个虚拟的第三方 jar,它有一个名为 hello() 的方法。您可以通过右键单击该项目并将其导出到 jar 来将该项目转换为 jar。非常简单。该第三方 jar 的代码非常简单。
之后,创建一个名为 HelloApplet 的简单小程序。它所拥有的只是显示一个小程序,然后调用我们的第三方 jar。将 jar 添加到 eclipse 中,如下面的屏幕截图所示。
这个 TestApplet 的源代码非常非常简单,如下所示。
右键单击该文件并选择作为 Applet 运行。就这样吧!您会看到您的小程序和消息也打印在控制台上!有什么疑问可以在评论区提问,我会尽力帮助!
You do the same way as you do for a program having a main() method. Goto properties --> Build path --> Jars. Add your third party jars there and the program should pick them up.
First create a dummy third party jar which has a single method called hello(). You can convert that project into a jar by right clicking on the project and exporting it to a jar. Its very simple. The code for that third party jar is very simple.
After this, create a simple applet called HelloApplet. All it has is just displaying an applet and in turn calling our third party jar. Adding the jar to the eclipse is shown as in the below screenshot.
The source code for this TestApplet is very very simple as shown below.
Right click on the file and select Run as Applet. There you go! You would both see your applet and the message getting printed on the console as well! Any doubts you have, ask in comments section, I will try to help!