Ido
Ido

Reputation: 255

Can i get the project build path programmatically?

I want to a project build path (default is src...). Can I do it using some java API?

Upvotes: 0

Views: 9873

Answers (5)

Mohammad Alkhateeb
Mohammad Alkhateeb

Reputation: 89

As i know you can get the project path as the following :

String projectPath = System.getProperty("user.dir");

Upvotes: 3

Peter
Peter

Reputation: 5798

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.

Upvotes: 0

McDowell
McDowell

Reputation: 108979

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.

Upvotes: 2

Benoit Courtine
Benoit Courtine

Reputation: 7074

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.

Upvotes: 0

skaffman
skaffman

Reputation: 403611

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)

Upvotes: 1

Related Questions