# Import failing under 1.1.5 and 1.1.6RC1

**URL:** <https://www.ruby-forum.com/t/import-failing-under-1-1-5-and-1-1-6rc1/154877>\
**Category:** JRuby\
**Created:** [December 4, 2008, 6:54pm UTC](https://www.ruby-forum.com/t/import-failing-under-1-1-5-and-1-1-6rc1/154877 "2008-12-04T18:54:30Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![supasta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ebca7d/32.png) [@supasta](https://www.ruby-forum.com/u/supasta)\
**Post date:** [December 4, 2008, 6:54pm UTC](https://www.ruby-forum.com/t/import-failing-under-1-1-5-and-1-1-6rc1/154877/1 "2008-12-04T18:54:30Z")

</div>

I have a class of the form “foo.\_2008\_08\_01.ClassName” and when I  
require the file that has this import, I get the following error:

“NameError: cannot load Java class foo.\_2008\_08\_01”

I have tried with 1.1.5 and 1.1.6RC1 with the same results. Any idea  
what might be going on here?

Thanks,  
Chris

---

<div class="post-metadata">

**Author:** ![supasta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ebca7d/32.png) [@supasta](https://www.ruby-forum.com/u/supasta)\
**Post date:** [December 4, 2008, 8:41pm UTC](https://www.ruby-forum.com/t/import-failing-under-1-1-5-and-1-1-6rc1/154877/2 "2008-12-04T20:41:29Z")

</div>

Chris W. wrote:

> I have a class of the form â€œfoo.\_2008\_08\_01.ClassNameâ€ and when I  
> require the file that has this import, I get the following error:
> 
> â€œNameError: cannot load Java class foo.\_2008\_08\_01â€
> 
> I have tried with 1.1.5 and 1.1.6RC1 with the same results. Any idea  
> what might be going on here?

Ugh…first smack whoever put that in the package name. Done? We can  
move on now. 🙂

There are a few ways you should be able to access the class. Have you  
tried import with “foo.\_2008\_08\_01.ClassName”? include\_class? If neither  
of those work we can find another way for you, probably something like  
this:

cls = java.lang.Class.forName ‘foo.\_2008\_08\_01.ClassName’  
ClassName = JavaUtilities.get\_proxy\_class(cls)

If you can come up with specs (for /spec/java\_integration in  
repo) we can look at making it work like you expect. File a bug.

- Charlie

* * *

To unsubscribe from this list, please visit:

```
http://xircles.codehaus.org/manage_email

```

---

<div class="post-metadata">

**Author:** ![supasta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ebca7d/32.png) [@supasta](https://www.ruby-forum.com/u/supasta)\
**Post date:** [December 4, 2008, 9:12pm UTC](https://www.ruby-forum.com/t/import-failing-under-1-1-5-and-1-1-6rc1/154877/3 "2008-12-04T21:12:02Z")

</div>

Unfortunately, I don’t have control over that package; though, I have  
Java programs that call that package, so I think it’s legal, if not  
ugly.

I’ve tried import and include\_class, and neither has worked. I think the  
other suggestion won’t work, because the class loader won’t know that  
class exists until I import it.

I’m happy to file a bug. What form should the specs take? Is the problem  
that JRuby doesn’t like a package beginning with an underscore,  
containing an underscore? Numbers? Only numbers? Etc.

Are there any other suggestions? I have to ship this by the end of next  
week ☹

Thanks for your help,  
Chris

On 12/4/08 11:40 AM, “Charles Oliver N.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

Chris W. wrote:

> I have a class of the form “foo.\_2008\_08\_01.ClassName” and when I  
> require the file that has this import, I get the following error:
> 
> “NameError: cannot load Java class foo.\_2008\_08\_01”
> 
> I have tried with 1.1.5 and 1.1.6RC1 with the same results. Any idea  
> what might be going on here?

Ugh…first smack whoever put that in the package name. Done? We can  
move on now. 🙂

There are a few ways you should be able to access the class. Have you  
tried import with “foo.\_2008\_08\_01.ClassName”? include\_class? If neither  
of those work we can find another way for you, probably something like  
this:

cls = java.lang.Class.forName ‘foo.\_2008\_08\_01.ClassName’  
ClassName = JavaUtilities.get\_proxy\_class(cls)

If you can come up with specs (for /spec/java\_integration in  
repo) we can look at making it work like you expect. File a bug.

- Charlie

* * *

To unsubscribe from this list, please visit:

```
http://xircles.codehaus.org/manage_email

```

---

<div class="post-metadata">

**Author:** ![supasta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ebca7d/32.png) [@supasta](https://www.ruby-forum.com/u/supasta)\
**Post date:** [December 4, 2008, 9:49pm UTC](https://www.ruby-forum.com/t/import-failing-under-1-1-5-and-1-1-6rc1/154877/4 "2008-12-04T21:49:06Z")

</div>

Hmm, seems the underscores were confusing the interpreter. Iâ€™ve always  
imported without quotes around the class name, but when I did (per your  
example), it worked like a charm.

Thanks for your help.

-chris

On 12/4/08 12:36 PM, “Charles Oliver N.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

There’s a bunch of specs under spec/java\_integration that should serve  
as good examples.

Have you tried it against 1.1.6RC1? It seems to work ok for me here…

[headius @ cnutter:~/projects/jruby]  
â—† cat foo/\_2008\_12\_05/MyClass.java  
package foo.\_2008\_12\_05;

public class MyClass {}  
[headius @ cnutter:~/projects/jruby]  
â—† javac foo/\_2008\_12\_05/MyClass.java  
[headius @ cnutter:~/projects/jruby]  
â—† CLASSPATH=. jruby -rjava -e “import ‘foo.\_2008\_12\_05.MyClass’; p  
MyClass.new”  
#\<Java::Foo\_2008\_12\_05::MyClass:0x5381298a  
@java\_object=foo.\_2008\_12\_05.MyClass@44594680\>

Chris W. wrote:

> ```
> > require the file that has this import, I get the following error:
> tried import with "foo._2008_08_01.ClassName"? include_class? If neither
> 
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
> 
> http://xircles.codehaus.org/manage_email
> 
> ```

* * *

To unsubscribe from this list, please visit:

```
http://xircles.codehaus.org/manage_email

```

---

<div class="post-metadata">

**Author:** ![supasta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ebca7d/32.png) [@supasta](https://www.ruby-forum.com/u/supasta)\
**Post date:** [December 4, 2008, 10:34pm UTC](https://www.ruby-forum.com/t/import-failing-under-1-1-5-and-1-1-6rc1/154877/5 "2008-12-04T22:34:24Z")

</div>

Chris W. wrote:

> Hmm, seems the underscores were confusing the interpreter. Iâ€™ve always  
> imported without quotes around the class name, but when I did (per your  
> example), it worked like a charm.

Confirmed…can you file a bug for this pleeeeez?

[headius @ cnutter:~/projects/jruby]  
â—† CLASSPATH=. jruby -rjava -e “import foo.\_2008\_12\_05.MyClass; p  
MyClass.new”  
-e:1: undefined local variable or method `foo' for main:Object (NameError) [headius @ cnutter:~/projects/jruby] â—† CLASSPATH=. jruby -rjava -e "import Java::foo._2008_12_05.MyClass; p MyClass.new" /Users/headius/projects/jruby/lib/ruby/site_ruby/1.8/builtin/java/ast.rb:49:in `get\_proxy\_or\_package\_under\_package’: cannot load Java class  
foo.\_2008\_12\_05 (NameError)  
from  
/Users/headius/projects/jruby/lib/ruby/site\_ruby/1.8/builtin/javasupport/java.rb:43:in  
`method\_missing’  
from -e:1

- Charlie

* * *

To unsubscribe from this list, please visit:

```
http://xircles.codehaus.org/manage_email

```

---

<div class="post-metadata">

**Author:** ![supasta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ebca7d/32.png) [@supasta](https://www.ruby-forum.com/u/supasta)\
**Post date:** [December 4, 2008, 9:36pm UTC](https://www.ruby-forum.com/t/import-failing-under-1-1-5-and-1-1-6rc1/154877/6 "2008-12-04T21:36:44Z")

</div>

There’s a bunch of specs under spec/java\_integration that should serve  
as good examples.

Have you tried it against 1.1.6RC1? It seems to work ok for me here…

[headius @ cnutter:~/projects/jruby]  
â—† cat foo/\_2008\_12\_05/MyClass.java  
package foo.\_2008\_12\_05;

public class MyClass {}  
[headius @ cnutter:~/projects/jruby]  
â—† javac foo/\_2008\_12\_05/MyClass.java  
[headius @ cnutter:~/projects/jruby]  
â—† CLASSPATH=. jruby -rjava -e “import ‘foo.\_2008\_12\_05.MyClass’; p  
MyClass.new”  
#\<Java::Foo\_2008\_12\_05::MyClass:0x5381298a  
@java\_object=foo.\_2008\_12\_05.MyClass@44594680\>

Chris W. wrote:

> ```
> > require the file that has this import, I get the following error:
> tried import with "foo._2008_08_01.ClassName"? include_class? If neither
> 
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
> 
> http://xircles.codehaus.org/manage_email
> 
> ```

* * *

To unsubscribe from this list, please visit:

```
http://xircles.codehaus.org/manage_email

```

---

<div class="post-metadata">

**Author:** ![supasta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ebca7d/32.png) [@supasta](https://www.ruby-forum.com/u/supasta)\
**Post date:** [December 4, 2008, 11:07pm UTC](https://www.ruby-forum.com/t/import-failing-under-1-1-5-and-1-1-6rc1/154877/7 "2008-12-04T23:07:27Z")

</div>

[http://jira.codehaus.org/browse/JRUBY-3218](http://jira.codehaus.org/browse/JRUBY-3218). Thanks as always for your  
help, Charles. Iâ€™ll try to make the problem more interesting next time  
🙂

-chris

On 12/4/08 1:33 PM, “Charles Oliver N.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

Chris W. wrote:

> Hmm, seems the underscores were confusing the interpreter. Iâ€™ve always  
> imported without quotes around the class name, but when I did (per your  
> example), it worked like a charm.

Confirmed…can you file a bug for this pleeeeez?

[headius @ cnutter:~/projects/jruby]  
â—† CLASSPATH=. jruby -rjava -e “import foo.\_2008\_12\_05.MyClass; p  
MyClass.new”  
-e:1: undefined local variable or method `foo' for main:Object (NameError) [headius @ cnutter:~/projects/jruby] â—† CLASSPATH=. jruby -rjava -e "import Java::foo._2008_12_05.MyClass; p MyClass.new" /Users/headius/projects/jruby/lib/ruby/site_ruby/1.8/builtin/java/ast.rb:49:in `get\_proxy\_or\_package\_under\_package’: cannot load Java class  
foo.\_2008\_12\_05 (NameError)  
from  
/Users/headius/projects/jruby/lib/ruby/site\_ruby/1.8/builtin/javasupport/java.rb:43:in  
`method\_missing’  
from -e:1

- Charlie

* * *

To unsubscribe from this list, please visit:

```
http://xircles.codehaus.org/manage_email

```
