简体   繁体   English

从Jruby中的Jar文件访问枚举

[英]Access enums from Jar file in Jruby

I'm trying to access the following static enum 我正在尝试访问以下静态枚举

public class Colors
{
    public enum ListofColors 
    {
        BLUE, RED, YELLOW
    }
}

But I keep getting the error 但我不断收到错误

NameError: cannot load Java class Colors.Colors::ListofColors::BLUE

When I try the following: 当我尝试以下操作时:

CL = JavaUtilities.get_proxy_class('Colors.Colors::ListofColors::BLUE')

but then I tried the following: 但后来我尝试了以下方法:

CL = JavaUtilities.get_proxy_class('Colors.Colors')
red = Colors.Colors::ListofColors::RED

And it gave me the following error: 它给了我以下错误:

NameError: uninitialized constant Colors

Is there a different way to get this static enum from the jar file and include it in Jruby without getting that errpr? 有没有其他方法可以从jar文件中获取此静态枚举并将其包含在Jruby中,而无需得到该errpr?

Thanks. 谢谢。

I think you need package::class, you repeated Colors twice 我认为您需要package :: class,重复两次Colors

also see 也看到

Problems Calling a Java Class from JRuby 从JRuby调用Java类时出现问题

figure out if java_import helps you https://github.com/jruby/jruby/wiki/CallingJavaFromJRuby 找出java_import是否可以帮助您https://github.com/jruby/jruby/wiki/CallingJavaFromJRuby

Also you dont seem to be using the variable CL, Try using 另外,您似乎没有使用变量CL,请尝试使用

CL::ListofColors::Blue CL :: ListofColors ::蓝

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM