我正在开发我的第一个 Java 应用程序,它实际上需要一个 3rd 方包,现在我不知道如何实际使用它.我需要的软件包来自 VLCJ,以便我可以在我的 GUI 中嵌入媒体播放器.
I'm developping my first Java application which actually needs a 3rd party package and now I'm lost as to how to actually use it. The packages I need are from VLCJ so that I can embed a media player in my GUI.
通常,我可以只导入包和类,但是这可以通过 3rd 方包实现吗?他们有一个 .jar 文件可以在他们的网站上下载,这些包是否存储在其中?如果是这样,我该如何在自己的应用程序中使用它们?
Usually, I can just import packages and classes, but is this possible with 3rd party packages? They have a .jar file to download at their website, are the packages stored in that? And if so, how do I go about using them in my own application?
您只需要将第三方 JAR 放在项目的类路径中.你用的是什么IDE?在 Eclipse 中你会这样做:
You just need the third party JAR to be on your project's classpath. What IDE are you using? In Eclipse you would do:
转到包资源管理器窗口左边.选择您所在的 Java 项目工作并右键单击.点击特性.然后点击 Java 构建小路.点击添加外部罐子.
Go to Package Explorer window on the left. Select the Java project you are working on and right click. Click Properties. Then click Java Build Path. Click Add External Jars.
或者您可以修改系统范围的 CLASSPATH 以包含 JAR.或者您可以在命令行上执行此操作,例如
Or you could modify your system wide CLASSPATH to include the JAR. Or you can do it on the command line e.g.
java -classpath C:java hirdpartjars hirdparty.jar MyProgram
(您也可以将参数与 javac
一起使用).
(you can use the argument with javac
too).
有很多方法可以解决这个问题.
There are many ways to crack this nut.
这篇关于如何在 Java 中使用 3rd 方包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!