tags:

views:

57

answers:

2

I installed a new hard drive with JDK 1.6.0_20 and Netbeans 6.9.1. I copied an existing Netbeans project from the old drive and imported it into NB 6.9.1.

Now it is suddenly creating output files and writing Log4J .log files in the c:\windows directory instead of the project directory.

I created the test class below outside of NB to see what is happening. Running this outside of NB gives the expected results. Importing this class into a new NB project also gives the expected results. But if I copy this class into the other project then it gives c:\windows for all 3 outputs.

What could be the problem with this one project that causes it to act like it's project directory is c:\windows?

public class DirectoryTest {

    public static void main(String[] args) {

        String userDir = System.getProperty("user.dir");
        System.out.println(userDir);
        File file = new File(".");

        try {
            System.out.println(file.getCanonicalPath());
            System.out.println(file.getAbsolutePath());
        } catch (Exception ex) {
            ex.printStackTrace();
        }

    }
}
A: 

Check the setting "Working directory" in the "Run" section of the project properties. Simply set your project's directory there.

a_horse_with_no_name
That had no effect. Log4j is still writing to c:\windows and the test program above still shows c:\windows for all three outputs.
Dean Schulze
Do you have multiple "Run" definitions? The output for log4j could be defined through a log4j.xml (or .properties) that's somewhere on your classpath. If you are 100% the run configuration that you are using has the correct directory defined, then I don't know what could be wrong there
a_horse_with_no_name
A: 

You could try deleting the nbproject & build folders and re-creating it as a "Project with Existing Sources".

As a last resort, delete the NetBeans cache folder from wherever it is stored on your platform, typically in a hidden folder of your home directory.

trashgod
That was the solution. I deleted all the nb* directories and the various build*.xml and nbbuild*.xml files and recreated it as you said. That project has seen several versions of NB, so it may have gotten confused.
Dean Schulze