我有一个试图从JRuby脚本启动的Java应用程序。我已经搜索了/t-拍摄/迭代了这么多解决方案--我的“基本”脚本是:
include Java
require 'c:/nm/bin/h4j.jar'
module HOLTER
include_package 'com.nemon.h4j.H4JFrame';
end
include_class Java::ComNemonH4j::H4JFrame
H4JFrame.new这将抛出以下错误:
TypeError: no public constructors for Java::ComNemonH4j::H4JFrame
(root) at h4j_initialTest.rb:7我发现这也抛出了同样的错误:
$nm = HOLTER::H4JFrame.new我的应用程序的主要构造函数是:
public static void main(String argv[])
{
captureOutput();
new H4JFrame(argv);
} 那么,我需要做什么才能让我的脚本简单地启动我的应用程序呢?任何/所有的建议和指示都将非常感谢!
发布于 2011-08-24 09:09:07
H4JFrame是否有0参数构造函数?在java main中,您显示了使用String argv[]作为参数来调用它,所以我假设它不是这样的。要使用当前代码启动应用程序,需要将Java String数组传递给H4JFrame。
include Java
require 'c:/nm/bin/h4j.jar'
module HOLTER
include_package 'com.nemon.h4j.H4JFrame';
end
include_class Java::ComNemonH4j::H4JFrame
str_arr = ["example input", "this is an array of strings", "it is a ruby object"]
H4JFrame.new(str_arr.to_java :String)https://stackoverflow.com/questions/6478811
复制相似问题