在Java Eclipse中导入外部库。

huangapple go评论94阅读模式
英文:

Importing external libraries in java eclipse

问题

我是Java应用程序编程的新手,想知道如何导入包?我正在使用Eclipse。

import java.io.IOException;
import java.net.MalformedURLException;
import se.kontoret.testapi.*;  //这是必需的。

它是否与.NET中的dll文件相同,其中必须有.dll文件并将其添加为引用?

英文:

I am new to java application programming. wondering how to import package? I am using Eclipse.

import java.io.IOException;
import java.net.MalformedURLException;
import se.kontoret.testapi.*;  //this is required.

Is it same like dll file in .net where one must have .dll files and add as reference?

答案1

得分: 1

有两种方法可以做到这一点:

  1. 下载这个扩展库,它的扩展名是 .jar,然后通过构建路径将其配置到一个普通的 Java 项目中。
  2. 你可以创建一个 Maven 项目,在其中添加依赖,这样 Maven 将会把它下载到你的 .m2 仓库中,然后你可以在代码中导入它。
英文:

There are two ways to do this:

  1. Downloaded the external library which is of .jar extension and Configure it using build path for a normal java project
  2. You can create a Maven project and add the dependencies there so that Maven will download it to your .m2 repo and you can import it in your code.

答案2

得分: 1

是的,它相似。

要做这个,请右键单击您的项目,导航到“Build Path” -> “Add external archives”,然后选择包含您外部依赖项的 .jar 文件。

英文:

Yes, it is similar.

To do this, right click on your project, navigate to Build Path -> Add external archives, and then select the .jar file which contains your external dependency.

huangapple
  • 本文由 发表于 2020年9月22日 16:54:27
  • 转载请务必保留本文链接:https://go.coder-hub.com/64006271.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定