open .java file in specified eclipse project from command line

假如想象 提交于 2019-12-23 06:23:44

问题


--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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!