加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

在jruby中导入java包中的所有类

发布时间:2020-12-17 02:20:54 所属栏目:百科 来源:网络整理
导读:参见英文答案 How can I import all packages in jruby?????????????????????????????????????1个 我正在寻找相当于的语法 import com.mycom.mypack.* 为jruby 例如java_import com.mycom.mypack. 此功能是通过JRUBY 6334 JIRA添加的 https://jira.codehaus.
参见英文答案 > How can I import all packages in jruby?????????????????????????????????????1个
我正在寻找相当于的语法

import com.mycom.mypack.*

为jruby

例如java_import com.mycom.mypack.

此功能是通过JRUBY 6334 JIRA添加的

https://jira.codehaus.org/browse/JRUBY-6334

但我不清楚实际的语法是什么.

以下是Jruby先生本人的评论:

Charles Oliver Nutter added a comment - 17/Feb/12 1:13 PM

commit a39a7440c21b411c4592a27d2ef9e0ca73736590
Author: Charles Oliver Nutter <headius@headius.com>
Date:   Fri Feb 17 13:06:24 2012 -0600

    Fix JRUBY-6334: Import multiple classes via java_import

    I opted to just go with the simple version to resolve this issue.
    I have nothing against introducing some syntax to import multiple
    classes from the same package,but I didn't see anything that we
    all agreed looked nice,and in any case you could use other Ruby
    constructs to build the list of full names you pass to java_import.

解决方法

require 'java'

module JavaUtil
  include_package "java.util"
end

JavaUtil::Date.new

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读