why the current directory not the target\classes?

Using maven for a project say myproject

it has the following myproject\src and myproject\target, and all the class and resources are copied to myproject\target\classes.

However i found the user.dir or current dir is still myproject, why not myproject\target\classes, how to change the current dir to myproject\target\classes?

Answers


Because maven always runs things in the working directory of the pom.xml, unless you configure it differently (which i think you can do in the surefire plugin which is what runs test cases).


If you want to get class folder path,you can following this code :

    String path  = YourClassName.class.getResource("").getPath();

Need Your Help

How to know the response time of my WPF application

.net testing response

I have a very simple application in WPF. It has some buttons, textboxes and shapes.