danlucraft / swt

Contains everything required to write cross-platform desktop applications with JRuby and SWT.
Other
35 stars 14 forks source link

Cannot require on Windows #12

Closed chuckremes closed 10 years ago

chuckremes commented 10 years ago

Win7x64, JRuby 1.7.6, swt 0.18

PS C:\Users\cremes\shoes4> jirb
irb(main):001:0> require 'java'
=> false
irb(main):002:0> require 'swt'
NameError: missing class or uppercase package name (`org.eclipse.swt.widgets.Display')
        from org/jruby/javasupport/JavaUtilities.java:54:in `get_proxy_or_package_under_package'
        from file:/C:/jruby-1.7.6/lib/jruby.jar!/jruby/java/java_package_module_template.rb:14:in `method_missing'
        from c:/jruby-1.7.6/lib/ruby/gems/shared/gems/swt-0.18/lib/swt/minimal.rb:12:in `Widgets'
        from c:/jruby-1.7.6/lib/ruby/gems/shared/gems/swt-0.18/lib/swt/minimal.rb:11:in `Swt'
        from c:/jruby-1.7.6/lib/ruby/gems/shared/gems/swt-0.18/lib/swt/minimal.rb:6:in `(root)'
        from org/jruby/RubyKernel.java:1082:in `require'
        from c:/jruby-1.7.6/lib/ruby/1.9/site_ruby/rubygems/custom_require.rb:1:in `(root)'
        from c:/jruby-1.7.6/lib/ruby/1.9/site_ruby/rubygems/custom_require.rb:36:in `require'
        from org/jruby/RubyKernel.java:1082:in `require'
        from c:/jruby-1.7.6/lib/ruby/gems/shared/gems/swt-0.18/lib/swt.rb:2:in `(root)'
        from c:/jruby-1.7.6/lib/ruby/1.9/site_ruby/rubygems/custom_require.rb:1:in `(root)'
        from org/jruby/RubyKernel.java:1121:in `eval'
        from c:/jruby-1.7.6/lib/ruby/1.9/site_ruby/rubygems/custom_require.rb:59:in `require'
        from (irb):2:in `evaluate'
        from org/jruby/RubyKernel.java:1517:in `loop'
        from org/jruby/RubyKernel.java:1282:in `catch'
        from org/jruby/RubyKernel.java:1282:in `catch'
        from c:\jruby-1.7.6\bin\jirb:13:in `(root)'irb(main):003:0>

Maybe the jar was built incorrectly?

Related to https://github.com/shoes/shoes4/issues/468

I suspect this is also related to:

https://github.com/danlucraft/swt/issues/9

Instead of using "minimal.rb" shoes4 probably needs everything.

PragTob commented 10 years ago

Hi there,

the JAR /should/ be good. The JAR is a straight copy from the SWT JARs (if it is messsed up it's my fault since I did the last update).

However what could be wrong is the JAR it is loading which might fail. E.g. the detection might be wrong.

The detection is done here - could you please print out/check what jar_path is? It should be the path to the swt-win64.jar if I understand your setup correctly.

Cheers, Tobi

chuckremes commented 10 years ago

I printed it out. It is:

c:/jruby-1.7.6/lib/ruby/gems/shared/gems/swt-0.18/vendor/swt/swt-win32

I should note that I am running the 32-bit JVM on Win7x64, so it looks to me like the detection is correct. Loading a 64-bit jar into a 32-bit JVM would be problematic.

On Oct 29, 2013, at 9:58 AM, Tobias Pfeiffer notifications@github.com wrote:

Hi there,

the JAR /should/ be good. The JAR is a straight copy from the SWT JARs (if it is messsed up it's my fault since I did the last update).

However what could be wrong is the JAR it is loading which might fail. E.g. the detection might be wrong.

The detection is done here - could you please print out/check what jar_path is? It should be the path to the swt-win64.jar if I understand your setup correctly.

Cheers, Tobi

— Reply to this email directly or view it on GitHub.

PragTob commented 10 years ago

Hm interesting. Just for kicks could you please post what RbConfig::CONFIG["host_cpu"] yields (you can do that in jirb)?

chuckremes commented 10 years ago

It returns "x86"

On Oct 29, 2013, at 10:13 AM, Tobias Pfeiffer notifications@github.com wrote:

Hm interesting. Just for kicks could you please post what RbConfig::CONFIG["host_cpu"] yields (you can do that in jirb)?

— Reply to this email directly or view it on GitHub.

wasnotrice commented 10 years ago

Instead of using "minimal.rb" shoes4 probably needs everything.

Shoes does need everything, but lib/swt.rb requires minimal first, then requires the rest.

PragTob commented 10 years ago

Hmmm then right now I don't have a clue of why it's not loading. It could be that the .jar is somehow defect or something as it does not seem to load the java classes but that's kind of unlikely... and the .class file is there in the JAR. So no idea why it does not load it... next step wourld probably be the build kind of a minimal example or something...

chuckremes commented 10 years ago

I can't even successfully "require 'swt'" without it blowing up. Hard to get more minimal than that. :)

PS C:\Users\cremes> jirb
irb(main):001:0> require 'swt'
loading 32 bit
"jar_path is c:/jruby-1.7.6/lib/ruby/gems/shared/gems/swt-0.18/vendor/swt/swt-win32"
"jar_path is c:/jruby-1.7.6/lib/ruby/gems/shared/gems/swt-0.18/vendor/swt/swt-win32"
NameError: missing class or uppercase package name (`org.eclipse.swt.widgets.Display')
        from org/jruby/javasupport/JavaUtilities.java:54:in `get_proxy_or_package_under_package'
        from file:/C:/jruby-1.7.6/lib/jruby.jar!/jruby/java/java_package_module_template.rb:14:in `method_missing'
        from c:/jruby-1.7.6/lib/ruby/gems/shared/gems/swt-0.18/lib/swt/minimal.rb:12:in `Widgets'
        from c:/jruby-1.7.6/lib/ruby/gems/shared/gems/swt-0.18/lib/swt/minimal.rb:11:in `Swt'
        from c:/jruby-1.7.6/lib/ruby/gems/shared/gems/swt-0.18/lib/swt/minimal.rb:6:in `(root)'
        from org/jruby/RubyKernel.java:1082:in `require'
        from c:/jruby-1.7.6/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:1:in `(root)'
        from c:/jruby-1.7.6/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:55:in `require'
        from org/jruby/RubyKernel.java:1082:in `require'
        from c:/jruby-1.7.6/lib/ruby/gems/shared/gems/swt-0.18/lib/swt.rb:2:in `(root)'
        from c:/jruby-1.7.6/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:1:in `(root)'
        from org/jruby/RubyKernel.java:1121:in `eval'
        from c:/jruby-1.7.6/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:135:in `require'
        from (irb):1:in `evaluate'
        from org/jruby/RubyKernel.java:1517:in `loop'
        from org/jruby/RubyKernel.java:1282:in `catch'
        from org/jruby/RubyKernel.java:1282:in `catch'
        from c:\jruby-1.7.6\bin\jirb:13:in `(root)'irb(main):002:0>
irb(main):003:0*

On Oct 29, 2013, at 10:29 AM, Tobias Pfeiffer notifications@github.com wrote:

Hmmm then right now I don't have a clue of why it's not loading. It could be that the .jar is somehow defect or something as it does not seem to load the java classes but that's kind of unlikely... and the .class file is there in the JAR. So no idea why it does not load it... next step wourld probably be the build kind of a minimal example or something...

— Reply to this email directly or view it on GitHub.

chuckremes commented 10 years ago

Any chance this is just a problem with the swt 4.3 release? If so, is it easy for me to build new jars from the latest swt snapshot and drop them in or is there a trick to it?

On Oct 29, 2013, at 10:29 AM, Tobias Pfeiffer notifications@github.com wrote:

Hmmm then right now I don't have a clue of why it's not loading. It could be that the .jar is somehow defect or something as it does not seem to load the java classes but that's kind of unlikely... and the .class file is there in the JAR. So no idea why it does not load it... next step wourld probably be the build kind of a minimal example or something...

— Reply to this email directly or view it on GitHub.

chuckremes commented 10 years ago

I installed the swt 4.3.1 and the problem persists. I googled around a bit and found two items of interest.

  1. https://gist.github.com/adamstegman/5077010

Which indicates that something else might be missing from the classpath but JRuby's error message doesn't contain enough information to figure out what it is.

  1. https://groups.google.com/forum/#!topic/redcar-editor/S6hPXoC8IeY

Someone had the same trouble when running redcar in a 32-bit JVM. The solution is unclear from that message thread. Looks like it might have been a problem with a JRuby 1.7 release candidate.

Hopefully one of these two items rings a bell or provides a hint for further research. I'm not a java expert (which is why I use Ruby :) so my ability to dig into the java side of things is limited.

chuckremes commented 10 years ago

I moved the imports for Widgets down below the Layout and Graphics modules to see if any components could be imported successfully. It apparently imported those fine because it complained about Display again. I then moved Display to the last line of the Widgets module. It then complained that it couldn't load Label. So, there is something specific to org.eclipse.swt.widgets that it doesn't like.

Then I looked at the jruby source. There is an option that can be passed on the command line related to the error message (-Xji.upper.case.package.names.allowed=true). I tried passing that and it gave a more detailed error message. I couldn't run this in windows powershell for some reason, so a screen shot is attached from a command prompt. screen shot 2013-10-29 at 1 35 34 pm

So, this gets further but it still can't find the Display class in org.eclipse.swt.widgets.

chuckremes commented 10 years ago

If someone can provide some pure java, I'd be happy to compile it and run it on my local computer to help narrow down the issue. Getting jruby out of the mix might be a good idea hence the suggestion. Please?

PragTob commented 10 years ago

Hi there,

well since all of this is jRuby stuff getting it out of the way might not be the best thing.

Yesterday Eric (@wasnotrice) suggested to simply try a `bundle update swt (or install) on the shoes4 repository. Otherwise you could also try uninstalling/installing the swt gem. Also just to make sure I didn't mess anything up during the last update you could try installing the 0.17 version of the swt gem.

For other help we'd need someone with Windows... my time is kind of low these days so I dunno when I'll get around to installing jruby/shoes on a windows partition. Sorry.

Tobi

chuckremes commented 10 years ago

Alas, downgrading to 0.17 has the same issue. :(

It must be something to do with running in a 32-bit environment on a 64-bit host.

On Nov 6, 2013, at 12:52 PM, Tobias Pfeiffer notifications@github.com wrote:

Hi there,

well since all of this is jRuby stuff getting it out of the way might not be the best thing.

Yesterday Eric (@wasnotrice) suggested to simply try a `bundle update swt (or install) on the shoes4 repository. Otherwise you could also try uninstalling/installing the swt gem. Also just to make sure I didn't mess anything up during the last update you could try installing the 0.17 version of the swt gem.

For other help we'd need someone with Windows... my time is kind of low these days so I dunno when I'll get around to installing jruby/shoes on a windows partition. Sorry.

Tobi

— Reply to this email directly or view it on GitHub.

chuckremes commented 10 years ago

Any chance I could pledgie $100 to @PragTob, @wasnotrice or @danlucraft to get this looked at? It would be worth it to me. :)

PragTob commented 10 years ago

Hi there,

I will totally look at it I just don't know when - my time is kinda limited and I'd need to setup a JRuby/shoes environment on a Windows machine. Maybe/hopefully I can get to it next week but no guarantees :-)

E.g. everything that is on the shoes4 issue tracker is kind of on my todo list, but with looking for a master thesis topic and several other commitments I only got so much time =)

Tobi

PragTob commented 10 years ago

Hi there @chuckremes

I'm sorry to say that I can not reproduce your problem. I just installed everything on my Windows7 x64 and it works like a charm.

E.g.:

So all that I can suggest at this point is trying to reinstall all that and kind of hope for the best.

Sorry, Tobi

chuckremes commented 10 years ago

My Win7x64 is in vmware, so I rolled back to the (almost) original install and updated it to the latest patch levels. I then installed the 32-bit JDK (jdk-1.7.0_45) and JRuby 1.7.8 and gem installed swt. The require 'swt' failed with the same error. :(

However, I also have a copy of Windows 8.1. I installed the same software there and the require succeeded. Looks like I'll be upgrading to Win8.1 in the near future.

Thank you for your help.

PragTob commented 10 years ago

Hi @chuckremes - that is so weird because I got exactly Win7x64 (well not in vmware but that should not matter).

What are you using "underneath" the Win7 vmware box? Actually I personally right now would recommend running shoes from either Linux or Mac.

Please let us know if this issue or a similar one pops up again.

Tobi

chuckremes commented 10 years ago

I'm running vmware on OSX 10.8.5. But, it shouldn't matter.

I need to deploy an app on Windows, so I have an incentive to get it (and keep it) running there.

On Nov 21, 2013, at 7:06 AM, Tobias Pfeiffer notifications@github.com wrote:

Hi @chuckremes - that is so weird because I got exactly Win7x64 (well not in vmware but that should not matter).

What are you using "underneath" the Win7 vmware box? Actually I personally right now would recommend running shoes from either Linux or Mac.

Please let us know if this issue or a similar one pops up again.

Tobi

— Reply to this email directly or view it on GitHub.