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 co开发者_Python百科nfigure it to have the lib folder in my dist folder during my build? Thank you.
Edit: Also, when I hit Run->Clean and Build Main Project, the output says the following:
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)
Why is it not copying the libraries during the build?
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
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 machine to 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.
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.
Hope help you.
The url provided by @fvu die. However I also have that problem and fixed it.
- Exit Netbean
- Delete your-project-name/nbproject/private
- Open Netbean
- Clean and build
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
Cheers.
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
delete the folder you add in these case 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.
Now you suppose to be good.
There is a setting in Net Beans. Right click on Net Beans project you have created.
Click on Build->Packaging. You will get 03 options on the right pane
- Compress JAR File
- Build JAR after Compiling
- Copy Dependent Libraries
Select the 03rd one and then build. You can see the /lib folder under /dist
精彩评论