2

I am able to create a default project in PDE just like mentioned here.

However I want to know how to create a Java project. How can I do that?

3 Answers 3

2

As a minimum you need to add the Java project nature to the project you create. Use something like:

private void addNatureToProject(IProject proj, String natureId, IProgressMonitor monitor) throws CoreException
{
    IProjectDescription description = proj.getDescription();

    String[] prevNatures = description.getNatureIds();

    String[] newNatures = new String[prevNatures.length + 1];

    System.arraycopy(prevNatures, 0, newNatures, 0, prevNatures.length);

    newNatures[prevNatures.length] = natureId;

    description.setNatureIds(newNatures);

    proj.setDescription(description, monitor);
}

The nature id for a Java project is 'org.eclipse.jdt.core.javanature' (also in the JavaCore.NATURE_ID constant).

Note that this does not add the various builders that are normally used in a Java project. The IProjectDescription.setBuildSpec method adds those in a similar way. Create a command for the build spec with:

ICommand command = description.newCommand();
command.setBuilderName(builderID);

where 'builderId' is 'org.eclipse.jdt.core.javabuilder' for the main Java builder (JavaCore.BUILDER_ID constant).

All this information is stored in the '.project' file in the project root folder. This is an XML file which you can look at to see the set up of existing projects.

Sign up to request clarification or add additional context in comments.

Comments

0

Window->Open Perspective->Java

then

File->New->Java Project (you may have to go via "Project..." to get to the "Java Project" option)

1 Comment

Thanks for the interest but you missed the real requirement as @Saagar Elias Jacky did I guess.
0

Please refer to New Project Creation Wizards

On the Plug-in Project page, use com.example.helloworld as the name for your project and check the box for Create a Java project (this should be the default). Leave the other settings on the page with their default settings and then click Next to accept the default plug-in project structure.

1 Comment

The link you provided is about using the eclipse's project wizard. I could not find any related information to the plugin development environment of Eclipse. I miss something?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.