How do I set the classpath in NetBeans?

后端 未结 2 1168
攒了一身酷
攒了一身酷 2020-11-22 10:39

Can someone tell me where and how I set the classpath in NetBeans? I would like to add a .jar file.

相关标签:
2条回答
  • 2020-11-22 11:30
    1. Right-click your Project.
    2. Select Properties.
    3. On the left-hand side click Libraries.
    4. Under Compile tab - click Add Jar/Folder button.

    Or

    1. Expand your Project.
    2. Right-click Libraries.
    3. Select Add Jar/Folder.
    0 讨论(0)
  • 2020-11-22 11:32

    Maven

    The Answer by Bhesh Gurung is correct… unless your NetBeans project is Maven based.

    Dependency

    Under Maven, you add a "dependency". 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. For the mathematical-minded, perhaps the phrase "Maven resolves the transitive dependencies" makes sense.

    Repository

    Maven gets this related-ness information, and the libraries themselves from a Maven repository. 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. That is the whole point to Maven, to make managing dependent libraries easy and to make building them into your project easy. To get started with adding a dependency, see this Question, Adding dependencies in Maven Netbeans and my Answer with screenshot.

    0 讨论(0)
提交回复
热议问题