0
我試圖獲得Netbeans中設置的主項目的路徑。查找在Netbeans中設置的主項目的路徑
import org.netbeans.api.project.ui.OpenProjects;
import org.netbeans.api.project.Project;
import javax.tools.FileObject;
Project proj = OpenProjects.getDefault().getMainProject();
FileObject root = proj.getProjectDirectory();
String path = root.getPath();
當執行下列錯誤時會產生。我發現比使用fileUtil而不是上面的root.getpath()。
Exception in thread "main" java.lang.NoClassDefFoundError: org/netbeans/modules/project/uiapi/Utilities
at org.netbeans.api.project.ui.OpenProjects.<init>(OpenProjects.java:88)
at org.netbeans.api.project.ui.OpenProjects.<clinit>(OpenProjects.java:83)