This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
See issue #43845 for possible utility method. Probably Add Project should cancel any attempt to create a cycle, and show an error message instead.
Creating cycle in J2SE project should not be possible.