I want to a project build path (default is src...). Can I do it using some java API?
The project default path is just a common used standard, most IDE's default to it but there are no Java API methods you can use.
There is a set of Ant tasks for this purpose. You could, in theory, use the Ant tasks as a Java API, albeit a rather clumsy one (unless you're actually writing in Ant, that is)
The project deault path is just a common used standard, most IDE's default to it but there > are no Java API methods you can use.
+1
The project path is a development convention, but the java application built is independant from this development path.
Most Java IDE allow you to change this path.
In Eclipse for example, this path can be changed with : Right clic on project folder > Properties > Java build path
If you need this path in external programs for build, Eclipse has internal variables that can be used (for Ant, Maven, etc.). When configuring an "external tool", you can for example use {$project_loc}. This will be dynamically replaced by the project path.
The question poster is writing an Eclipse plugin.
You can find the JDT API in the Eclipse help. You should be able to get the information you want from IJavaProject. See this tutorial for one example of how to get this.