Aptana に機能を追加しようとしていますが、この機能を使用するには、gem がシステム上のどこにあるかを調べる必要があります。Rubyでは、次のようなコマンドを実行します...
gem_folder_path = `rvm gemdir`
Java には明らかに対処すべき要素が他にもありますが、私が実装しようとしている Java ソリューションは、Eclipse/Aptana IDE の範囲内では機能しないようです (スタンドアロンでテストしたところ、私の helloworld.java ファイル)。シェルコマンドが無効になっていますか?
これが機能しない私の現在のJavaソリューションです。
public static String getGemsDirectory()
{
try
{
Process proc = Runtime.getRuntime().exec("which ruby");
BufferedReader stdInput = new BufferedReader(new
InputStreamReader(proc.getInputStream()));
BufferedReader stdError = new BufferedReader(new
InputStreamReader(proc.getErrorStream()));
String s;
String commandOutput = "";
// read the output from the command
System.out.println("Here is the standard output of the command:\n");
while ((s = stdInput.readLine()) != null) {
//System.out.println(s);
commandOutput += s;
}
// read any errors from the attempted command
System.out.println("Here is the standard error of the command (if any):\n");
while ((String s = stdError.readLine()) != null) {
//System.out.println(s);
commandOutput += s;
}
int statusCode = proc.exitValue();
return commandOutput;
}
catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
return "";
}
}