从命令行在指定的eclipse项目中打开.java文件 [英] open .java file in specified eclipse project from command line

查看:324
本文介绍了从命令行在指定的eclipse项目中打开.java文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

- launcher.openFile 打开文件而不将其分配给任何项目,因此不同的功能(如代码辅助)不起作用。我实际上正在尝试自动创建一个源文件,并希望编辑它,就像我在eclipse中默认创建它。

--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()});
}


推荐答案

让生成器写入文件到一个被称为eclipse的源目录的directoty。当你在eclipse中启用自动刷新时,它会更新它的索引,当你用启动器打开新生成的文件。

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.

这篇关于从命令行在指定的eclipse项目中打开.java文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆