问题
I'm using NetBeans 7.0.1 & when I try to create a JAVA APPLICATION, I get an error which is: "Project Folder already exists and is not empty" .
But the fact is that project folder doesn't exist, their is no folder of same name in the directory. Any suggestions would be a great help.
Thanks in advance.
回答1:
Does the problem comes out when you try to create it, or what ?
Please not that your version is a bit old.
Make sure that it was always in the same directory as before .
I would restart my computer & try again.
If the situation persists I would upgrade to the latest version (7.2.1) and check if the problem still persists or contact NetBeans.
回答2:
I my case (NetBeans 8.1 on Windows 7 x64) the reason was incorrect template file for main java class (C:\Users\_my_user_name_\AppData\Roaming\NetBeans\8.1\config\Templates\Classes\Main.java
). You see, when tweaking with that file I left it filled with invalid code; a closing tag was missing, to be exact. As soon as I realized my mistake and corrected it, everything went back to normal and has been working perfectly ever since.
This is what I'd suggest:
Step 1: See if you can create a new project in a folder that doesn't exist yet. Suppose the IDE does make this new folder for you, starts filling it with files, then stops unexpectedly and says that 'Project folder already exists, etc'.
Step 2: Look inside the folder and try to locate the main class for your application (e.g., C:\My_Amazing_NetBeans_Projects\MyNiftyJavaApp\src\myniftyjavaapp\MyNiftyJavaApp.java
)
Step 3: If the main class file does exist but is totally empty (0 bytes in length) it might mean that something prevents the IDE from filling it with automatically generated code (as happened to me because of the invalid main class template).
In short, try to locate exact point at which the IDE loses its head. As a last resort, consider reinstalling NetBeans. Admittedly, this solution is crude and inelegant but people all over the world report it usually helps...
回答3:
<#if package?? && package != "">
package ${package};
</#if>
/** @author ${user} */
public class ${name} {
public static void main(String[] args) {
}
}
It seems that the first three lines of code above are key to this problem. I changed my JAVA MAIN CLASS
template and removed unwanted comments, but I also removed these first three lines of code. The first project created was ok, package was "default package".
When I tried to create the next project I got an error about a Project folder that already exists. I did uninstall/install NetBeans 8.2, changed template again in the same manner, and again second project fails to create.
Then I decided to change template line by line to see what is going on and guess what: the first three lines are necessary - new projects are created well and package is not default anymore!
来源:https://stackoverflow.com/questions/14228973/project-folder-already-exists-and-is-not-empty-error-in-netbeans