简体   繁体   English

如何在NetBeans中设置类路径?

[英]How do I set the classpath in NetBeans?

Can someone tell me where and how I set the classpath in NetBeans? 有人能告诉我在NetBeans中设置类路径的位置和方式吗? I would like to add a .jar file. 我想添加一个.jar文件。

  1. Right-click your Project. 右键单击您的项目。
  2. Select Properties . 选择Properties
  3. On the left-hand side click Libraries . 在左侧单击“ Libraries
  4. Under Compile tab - click Add Jar/Folder button. 在“ Compile tab - 单击“ Add Jar/Folder按钮。

Or 要么

  1. Expand your Project. 扩展您的项目。
  2. Right-click Libraries . 右键单击“ Libraries
  3. Select Add Jar/Folder . 选择Add Jar/Folder

Maven Maven的

The Answer by Bhesh Gurung is correct… unless your NetBeans project is Maven based. Bhesh Gurung回答是正确的......除非您的NetBeans项目是基于Maven的。

Dependency 依赖

Under Maven, you add a "dependency". 在Maven下,你添加一个“依赖”。 A dependency is a description of a library (its name & version number) you want to use from your code. 依赖项是要从代码中使用的库(其名称和版本号)的描述。

Or a dependency could be a description of a library which another library needs ("depends on"). 或者依赖关系可以是另一个库需要的库的描述(“依赖于”)。 Maven automatically handles this chain, libraries that need other libraries that then need other libraries and so on. Maven自动处理这个链,需要其他库然后需要其他库的库等等。 For the mathematical-minded, perhaps the phrase "Maven resolves the transitive dependencies" makes sense. 对于具有数学意识的人来说,也许短语“Maven解决了传递依赖”是有道理的。

Repository 知识库

Maven gets this related-ness information, and the libraries themselves from a Maven repository . Maven从Maven存储库获取这些相关信息,以及库本身。 A repository is basically an online database and collection of download files (the dependency library). 存储库基本上是在线数据库和下载文件集合(依赖库)。

Easy to Use 使用方便

Adding a dependency to a Maven-based project is really quite easy. 向基于Maven的项目添加依赖项非常简单。 That is the whole point to Maven, to make managing dependent libraries easy and to make building them into your project easy. 这就是Maven的重点,使管理依赖库变得容易,并使它们很容易构建到您的项目中。 To get started with adding a dependency, see this Question, Adding dependencies in Maven Netbeans and my Answer with screenshot . 要开始添加依赖项,请参阅此问题, 在Maven Netbeans中添加依赖项以及使用屏幕截图 添加 我的答案

在此输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM