我正在尝试从Java代码启动JRuby控制台。我试过的JRuby 9.2.5.0和JRuby安装的“bin”的使用jirb_swing脚本(后在此代码移除1号线)。我做了从我CenoOS一个JRuby的脚本启动控制台这个Java代码Linux操作系统:
import org.jruby.Ruby;
import org.jruby.RubyInstanceConfig;
import java.io.*;
public class RubyConsoleStandalone implements Runnable {
final String consolefile="/home/myname/jirb_swing.rb";
private RubyInstanceConfig config;
public void run() {
RubyInstanceConfig conf = new RubyInstanceConfig();
try {
Ruby rubyRuntime = Ruby.newInstance(conf);
String jRubyHome = System.getProperty("jruby.home");
String jRubyVersion = System.getProperty("jruby.version");
rubyRuntime.evalScriptlet("require 'jruby';");
rubyRuntime.evalScriptlet("require '"+consolefile+"';");
} catch (Exception e) {
e.printStackTrace();
}
} }
并运行以下代码:
public class Main {
public static void main(String[] args) {
RubyConsoleStandalone console = new RubyConsoleStandalone();
Thread t = new Thread("JRuby console") {
public void run() {
RubyConsoleStandalone console = new RubyConsoleStandalone();
console.run();
};
};
t.start();
}
}
错误是:
irb / completion-java.lang.IncompatibleClassChangeError:实现类
如果我删除了需要“IRB /完成”,然后在控制台的邀请,永远不会发生(但框弹出,但是没有提示符下键入命令)