I've got a little project in Spring. It's located (for example) in C:/users/projects/blog
. How can I get this path?
The pwd command can be used to determine the present working directory. and the cd command can be used to change the current working directory.
Spring Boot - Using ${} placeholders in Property Files. ☰ LOGICBIG.
In Java, we can use System. getProperty("user. dir") to get the current working directory, the directory from where your program was launched.
To print the current working directory, we use the pwd command in the Linux system. pwd (print working directory) – The pwd command is used to display the name of the current working directory in the Linux system using the terminal.
Maybe this what you looking for:
System.getProperty("user.dir")
This property returns user working directory for application.
Java cannot determine the root of your project without projects meta data. You can get the absolute path to your current class executing the code using the following : YourClassName.class.getResource("").getPath()
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