0

I tried to get the path of main project set in 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();

When executing the following error is generated. i found than fileUtil is to be used instead of the above 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)
Raj
  • 440
  • 2
  • 6
  • 22

1 Answers1

1

Try to search for the package in the module properties > Libraries > Add Dependency:

netbeans module properties

This however requires that in the Nebeans Platform project you've added dependency on that Platform Module (probably in ide > Project API)

Tombart
  • 30,520
  • 16
  • 123
  • 136