I have an Eclipse plugin that automatically loads existing Eclipse Java project to workspace, opens it and finally runs the Java application. If the Java project already exists in the workspace, the plugin refreshes the project relative to the project on the file system.
When doing only refreshing the plugin works fine, but when the plugin first imports the project by calling IProject.create(), opens it and runs it, I get a error dialog saying that program was not found.
The IProject.create() and open() are said to be long-running operations. Is there some way wait until the IProject.create() is finished then and then call IProject.open and after compliting the open methdod call the project.run() method?
IProject#create()
and IProject#open()
are both blocking methods, so you don't have to do anything special to "wait for them" -- when control returns to the call site, they're done creating and opening the project respectively.
Does the project contain Java source that needs to be compiled? If so you should probably also build the project after opening it and before attempting to run the Java program therein. Try using this:
project.build(IncrementalProjectBuilder.FULL_BUILD, monitor);