Note that there are some explanatory texts on larger screens.

plurals
  1. POCreate Eclipse project from standalone Java application
    primarykey
    data
    text
    <p>Is there a way to create a new Eclipse Java project from a standalone Java application, i.e. create a directory with the files .project, .classpath, src and bin folder?</p> <p>All solutions I found so far seem to target Eclipse plugins. I'd like to integrate the code into a rather large application that is generating Java source code. So, I'd rather like to stay standalone and independant from Eclipse (using single jar files would be ok, though).</p> <p>That's about what I've found so far in several samples:</p> <pre><code> // create Eclipse project IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); IProject project = root.getProject("SampleProject"); project.create(null); project.open(null); // make Java project IProjectDescription description = project.getDescription(); description.setNatureIds(new String[] { JavaCore.NATURE_ID }); project.setDescription(description, null); IJavaProject javaProject = JavaCore.create(project); // create bin folder - set output location IFolder binFolder = project.getFolder("bin"); binFolder.create(false, true, null); javaProject.setOutputLocation(binFolder.getFullPath(), null); // add source folders, change classpath,... don't want to be too verbose here </code></pre> <p>Unfortunately, that code is not suitable for standalone Java applications and would result in an IllegalStateException in the first line saying that the workspace was closed. Is there a better way to solve that problem? In fact, I don't really need any workspace at all, just want to create a single project with .project and .classpath file to ease importing the project for others.</p> <p>Yes, I've found a lot of similar questions (e.g. <a href="https://stackoverflow.com/questions/251807/programmatically-generate-an-eclipse-project">Programmatically generate an Eclipse project</a>) - but none of them seems to solve the issue without Eclipse integration.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload