In Netbeans what is the correct way to get the file path of the currently Opened Project. In the module I am developing I need to acquire the path of the Project for a FileChooser however most of what I tried simply returned the path of the module it is executing from. Is their a way to get the path of the Project that the method is run from?
Try to get a Project instance via lookup and then
        private String getProjectDirectory(final Project project) {
            try {
                FileObject projectDirectory = project.getProjectDirectory();
                return FileUtil.toFile(projectDirectory).getAbsolutePath();
            } catch (Exception e) {
                //ignore the exception
                return null;
            }
        }
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With