java Netbeans 未在 dist 文件夹中构建 lib 文件夹

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7264358/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 19:20:21  来源:igfitidea点击:

Netbeans not building the lib folder in the dist folder

javanetbeans

提问by O_O

I am trying to clean and build a jar but for some reason when I do a Run-> Clean and Build Main Project, I don't get a lib folder in the dist folder. This is causing a missing classes error when I run my jar file via cmd. How do I configure it to have the lib folder in my dist folder during my build? Thank you.

我正在尝试清理和构建一个 jar,但是由于某种原因,当我执行运行-> 清理并构建主项目时,我在 dist 文件夹中没有得到 lib 文件夹。当我通过 cmd 运行我的 jar 文件时,这会导致缺少类错误。如何在构建期间将其配置为在我的 dist 文件夹中包含 lib 文件夹?谢谢你。

Edit: Also, when I hit Run->Clean and Build Main Project, the output says the following:

编辑:另外,当我点击 Run->Clean and Build Main Project 时,输出如下:

2 warnings compile: Created dir: C:\Documents and Settings\me\Desktop\ProjectX\ProjectX\dist C:\Documents and Settings\me\Desktop\ProjectX\ProjectX\dist\ProjectX.jar is a directory or can't be read. Not copying the libraries. Not copying the libraries. Building jar: C:\Documents and Settings\me\Desktop\ProjectX\ProjectX\dist\ProjectX.jar To run this application from the command line without Ant, try: java -jar "C:\Documents and Settings\me\Desktop\ProjectX\ProjectX\dist\ProjectX.jar" jar: BUILD SUCCESSFUL (total time: 3 seconds)

2 警告编译: Created dir: C:\Documents and Settings\me\Desktop\ProjectX\ProjectX\dist C:\Documents and Settings\me\Desktop\ProjectX\ProjectX\dist\ProjectX.jar is a directory or can't被阅读。不复制库。不复制库。构建 jar:C:\Documents and Settings\me\Desktop\ProjectX\ProjectX\dist\ProjectX.jar 要在没有 Ant 的情况下从命令行运行此应用程序,请尝试: java -jar "C:\Documents and Settings\me\Desktop \ProjectX\ProjectX\dist\ProjectX.jar" jar: BUILD SUCCESSFUL (总时间: 3 秒)

Why is it not copying the libraries during the build?

为什么在构建过程中不复制库?

采纳答案by fvu

According to this forum.netbeans.org(cached copy as forums.netbeans.org is not accessible atm)article this could be caused by ProjectX.jar being added to the required JARs for some mysterious reason... Could be worth checking

根据这个forum.netbeans.org(缓存副本,因为forums.netbeans.org无法访问atm)文章这可能是由于某些神秘原因将ProjectX.jar添加到所需的JAR中引起的......可能值得检查

EDIT: cached copy seems to have disappeared, the original thread can be found here.

编辑:缓存副本似乎已经消失,原始线程可以在这里找到。

EDIT again: as both the original and the cached copy have disappeared, head over to the wayback machineto read the article. That being said, anno 2018+ one should probably consider using a more modern / widespread project format like Maven, which is also well supported by Netbeans and offers a much more flexible libraries management approach.

再次编辑:由于原始副本和缓存副本都消失了,请前往回溯机器阅读文章。话虽如此,anno 2018+ 应该考虑使用更现代/更广泛的项目格式,如 Maven,Netbeans 也很好地支持它并提供更灵活的库管理方法。

回答by Zamir Pe?a

In my case I went to Libraries->Properties. The "lib" folder was added as a library. remove it or remove them (several folders as libraries) and do clean and build.

就我而言,我去了图书馆-> 属性。“lib”文件夹被添加为一个库。删除它或删除它们(几个文件夹作为库)并进行清理和构建。

Hope help you.

希望能帮到你。

回答by Haha TTpro

The url provided by @fvu die. However I also have that problem and fixed it.

@fvu 提供的 url 死了。但是我也有这个问题并修复了它。

  1. Exit Netbean
  2. Delete your-project-name/nbproject/private
  3. Open Netbean
  4. Clean and build
  1. 退出网豆
  2. 删除您的项目名称/nbproject/private
  3. 打开网豆
  4. 清洁和构建

回答by D.G. Kang

In my case, I solved the same problem as follows : 1) Go to Project > Libraries > Properties > Libraries > Compile 2) Select missing libraries beginning 'Missing library :' and remove them 3) Clean and build

就我而言,我解决了以下相同的问题:1) 转到项目 > 库 > 属性 > 库 > 编译 2) 选择以 'Missing library :' 开头的缺失库并删除它们 3) 清理并构建

Cheers.

干杯。

回答by Janet Batlle

The problem is that you add the folder where are you libraries, you need to actually add the libraries and not the folder where they are.

问题是您添加了库所在的文件夹,您需要实际添加库而不是它们所在的文件夹。

1) Go to Project > Libraries > Properties > Libraries > Compile

1)转到项目>库>属性>库>编译

delete the folder you add in these case C:\Documents and Settings\me\Desktop\ProjectX\ProjectX\dist

删除您在这些情况下添加的文件夹 C:\Documents and Settings\me\Desktop\ProjectX\ProjectX\dist

Select add JAR/Folder and these time open the folder and add all the libraries inside, Netbeans will allow you to select it all.

选择添加 JAR/文件夹,这一次打开文件夹并添加其中的所有库,Netbeans 将允许您将其全部选中。

Now you suppose to be good.

现在你应该很好。

回答by Debarchan Dash

There is a setting in Net Beans. Right click on Net Beans project you have created.

Net Beans 中有一个设置。右键单击您创建的 Net Beans 项目。

Click on Build->Packaging. You will get 03 options on the right pane

单击构建-> 打包。您将在右侧窗格中看到 03 个选项

  • Compress JAR File
  • Build JAR after Compiling
  • Copy Dependent Libraries
  • 压缩 JAR 文件
  • 编译后构建JAR
  • 复制依赖库

Select the 03rd one and then build. You can see the /lib folder under /dist

选择第 03 个,然后构建。可以看到/dist下的/lib文件夹