问题
--launcher.openFile
opens file without assigning it to any project, so different features such as code assist don't work. I am actually trying to create a source file automatically and want to edit it just like I created it by default way in eclipse.
private void openInEclipse(File file) throws IOException {
String eclipsePath = "G:/eclipse/eclipse-java-juno-win32/eclipse/eclipse.exe";
Runtime.getRuntime().exec(new String[]{eclipsePath, file.getAbsolutePath()});
}
回答1:
Let the generator write the file into a directoty that is known as a source directory to eclipse. When you also enable automatic refresh in eclipse it will update it's index when you open the newly generated file with the launcher.
来源:https://stackoverflow.com/questions/11798201/open-java-file-in-specified-eclipse-project-from-command-line