相关文章
更多最近更新
更多怎么在java里面调用jruby类
2019-03-25 13:37|来源: 网路
大家是怎么用jruby的啊?
找了很久都没有java调用jruby的文章
难道不这样用的?
java应该怎么调用jruby呢? 大侠请指教
找了很久都没有java调用jruby的文章
难道不这样用的?
java应该怎么调用jruby呢? 大侠请指教
相关问答
更多-
Jruby使用Rubymine在另一个目录中扩展java类(Jruby extend java class in another directory using Rubymine)[2022-01-12]
据我所知,RubyMine(购买了许可但从未真正使用过它)不包括对.java的支持(甚至不是语法高亮显示) - 动机似乎是他们有一个单独的产品是Java IDE 。 因此,这个答案不会特定于RubyMine: 首先,您需要编译.java源代码并将它们打包在.jar中,或者只记住.class文件所在的目录( javac -d OUT_DIR ) 比你的.rb require 'path/to/packed.jar'或者只需$CLASSPATH << 'path/to/classes/OUT_DIR' ...比 ... -
'require'代替'java_import'。 require 'java' java_import com.package.MyClass 有关更多讨论,请参阅JRuby:import vs include vs java_import与include_class ,例如,为什么您应该使用'java_import'而不是'import' Instead of 'require', you want 'java_import'. require 'java' java_import com.packa ...
-
如何为从JRuby调用的Java jar设置log4j日志记录级别(How to set log4j logging levels for Java jars called from JRuby)[2024-05-03]
我通过设置JVM选项JRuby样式来实现这一点: export JRUBY_OPTS="-J-Dlog4j.debug=true -J-Dlog4j.configuration=file:/absolute/path/to/log4j.properties" trinidad 这覆盖了我的Java jar中指定的log4j.properties,我能够在jar文件中操作Java类的日志级别(并由类显式调用)。 I got this to work by setting JVM options JRuby- ... -
当从ruby调用java时,JRuby无法强制将类型强制转换为自身(JRuby failing to coerce a type to itself when calling java from ruby)[2023-04-19]
事实证明,这是一个与类加载器有关的问题。 在代码的每个位置使用了两个独特的类加载器。 解决方案是使用与创建脚本环境的代码相同的类加载器初始化JRuby脚本引擎。 engine = new ScriptingContainer(LocalContextScope.SINGLETHREAD, LocalVariableBehavior.PERSISTENT); engine.setCompileMode(RubyInstanceConfig.CompileMode.JIT); engine.setCompatV ... -
require 'java' module JavaUtil include_package "java.util" end JavaUtil::Date.new require 'java' module JavaUtil include_package "java.util" end JavaUtil::Date.new
-
我认为默认情况下不会查看JAR内部。 我创建了一个小测试,并能够重现您的问题。 然后我touch data.json ,代码不再出错。 我不确定如何指定您要查看JAR中的数据文件。 I don't think that it is going to look inside the JAR by default. I created a small test and was able to reproduce your issue. I then did touch data.json and the cod ...
-
类路径文件名不应以/开头。 它应该只是: container.runScriptlet(PathType.CLASSPATH, "installer.rb"); 这是Java的ClassLoader API的一个古怪的未记录的方面 (当然,它被ScriptingContainer用于从类路径加载文件)。 This is the code that finally got it to work: container.setArgv(args); InputStream is = this.getClass( ...
-
是否可以从JRuby创建Java类并在Java中使用它们?(Is it possible to create Java classes from JRuby and use them in Java?)[2022-07-14]
根据我的理解,我猜你正在尝试创建一个扩展Java类(使用脚本引擎)的JRuby类,并将该类交还给Java。 您的Ruby类可能如下所示: require 'java' require 'lucene-core.jar' java_import 'org.apache.lucene.analysis.Analyzer' java_import 'org.apache.lucene.analysis.standard.StandardTokenizer' java_import 'org.apache.luc ... -
com听起来像包名称,你想要的是将CP添加到CP: $CLASSPATH << File.expand_path('lib') # now import the class with the full name (including package) : java_import 'com.class1' # ... or simply just : Java::com.class1 但假设它是一个(编译).rb脚本,也许你只是想加载它: $LOAD_PATH << 'lib' require 'class ...
-
JRuby调用了错误的方法(JRuby calls the wrong method)[2024-01-10]
您可以修复cannot convert instance of class org.jruby.RubyModule to class java.lang.Class使用java.lang.Class.for_name cannot convert instance of class org.jruby.RubyModule to class java.lang.Class java.lang.Class.for_name 在你的情况下,它是 add_renderer = renderer.java_met ...