Netbeans 7: How to properly create a Java project from an existing source?

Starting with the following file structure:

doc/ lib/ src/%java-like structure% test/%java-like structure% build.xml 

I want to create a new Netbeans project (inside this structure) using an existing

  • assembly file
  • sources
  • libraries
  • other files

Using the Netbeans tutorial to create a project from an existing source, I can import the sources and test files, but there are problems:

  • You must select a name for the assembly file when you try it with an existing assembly file. Netbeans Blocks
  • After creating a project, Netbeans does not find the library packages in .lib/ , whether it is in the folder in the Properties / Libraries section or not.

As suggested here , I want to create a project from the git repository, but the proposed solution does not work for me (git does not want to clone into a non-empty directory ...), and I doubt that this will help with the library problem, etc.

EDIT 1

Somehow it works to create a new Netbeans project, then add libraries to it and import the library packages. But this does not work when creating a project from existing sources (then Netbeans does not find packages)!

EDIT 2

It seems even more complicated: it also does not work when I create a new project, change the source folder to the directory where the sources are (from which I want to create the project), and add the libraries, But use the libraries in the new project using new sources.

+4
source share
3 answers

You have two options:

1) Use a free form project. When you do this, you can specify your build.xml file that NetBeans will use (then it will not complain, since NB will not create its own build.xml)

2) Do not use the directory in which your project is stored as the "NetBeans Project Folder". Only NetBeans internal elements are stored in the NetBeans project folder, and there is no need to mix them with your sources, especially when they are versioned. You can use any directory for the "NetBeans Project Folder".

+3
source
  • AFAIK you cannot import the assembly file. You can rename it before opening the project or inform NB about creating an assembly file with a different name.
  • In the project properties, you can select libraries one at a time, pointing to banks in the lib folder

EDITED 2. Right-click on the node project in the left pane, select properties. The project properties window opens. See screenshots here: http://netbeans.org/kb/docs/java/project-setup.html . In the categories pane on the left, select the libraries. Then in the "compile" panel in the middle, click the "Add JAR / Folder" button and add banks. You can try to add the whole folder, I have not tried it yet, but I can work ...

+1
source

Well, it looks like Netbeans is a little buggy there.

Although I reloaded the project or restarted the IDE before it somehow didn't work. It was even that Netbeans released several endless directories with lib/lib/lib/lib/... or so.

After some attempts, he worked with a "project from an existing source." I added libraries with the option "Add JAR / Folder", selected all jar files and worked. I did not select the source lib folder in the project / library properties field. Perhaps this was a problem before.

0
source

All Articles