Reputation: 4111
Can I from code get the absolute path of Java a project in Eclipse ex C:\workspace\proj1
?
Thing is that code will be runned on different machines, so path will be different, depending on the machine.
Is there a way to achieve that?
Upvotes: 1
Views: 798
Reputation: 24998
You can use System.getProperty("user.dir")
and find the directory from which the program is run. If you look at the docs, you will get the description below:
user.dir User's current working directory
public class Ideone
{
public static void main (String[] args) throws java.lang.Exception
{
System.out.println(System.getProperty("user.dir"));
}
}
Upvotes: 2