danlucraft / swt

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

NameError: uninitialized constant Swt #9

Open DouglasAllen opened 10 years ago

DouglasAllen commented 10 years ago

I'm on Windows XP 32 Using pik and jruby 1.7.4 (1.9.3p392) 2013-05-16 2390d3b on Java HotSpot(TM) Client VM 1.7.0_25-b17 [Windows XP-x86]

I can run the sample button.rb which uses the swt lib from the repo. If I comment out the line $:.unshift(File.expand_path("../../lib", FILE)) and the swt gem is installed in C:\jruby-1.7.4\lib\ruby\gems\shared\gems\swt-0.16

I get that NameError: uninitialized constant Swt

Now that's from my G:\ drive with all my local repos.

If I go to C:\ where jruby is and run jruby -S jirb

require 'swt' => true Swt.constants NameError: uninitialized constant Swt

This all started when I tried to run shoes4 which depends on swt gem version 0.16

Clearly something is not right for my windows install. Can you help me?

PragTob commented 10 years ago

Hi Douglas, this is where the JAR loader should end up.

Could you give me the output of RbConfig::CONFIG["host_os"] and RbConfig::CONFIG["host_cpu"] from your PC?

you can just type them into IRB.

Cheers, Tobi

edit: from your JRuby installation of course :-)

talgorn commented 10 years ago

Hi Tobi,

On Windows8, x64 architecture: jruby 1.7.4 (1.9.3p392) 2013-05-16 2390d3b on Java HotSpot(TM) 64-Bit Server VM 1.6.0_41-b02 [Windows 8-amd64]

RbConfig::CONFIG["host_os"] is "mswin32" RbConfig::CONFIG["host_cpu"] is "x86_64

The issue is that some important SWT classes are not accessible:

For a button Widget, Swt::Widgets::Button.new(my_shell, Swt::SWT::PUSH) -> OK, NO PB.

But for a Canvas widget (same with Group),

Swt::Widgets::Canvas.new(my_shell, Swt::SWT::NONE) -> NameError: uninitialized constant Swt::Widgets::Canvas const_missing at org/jruby/RubyModule.java:2631

I checked the Vendor jars (swt-win32.jar andswt-win64.jar), path to jars are OK and clsses are in the jars with the proper name !

I spent 2 days now on this one and i need Group and Canvas. Could you please tell me if you have a solution for this ?

Thank you !

François-Xavier.

danlucraft commented 10 years ago

When I initially created this gem for Redcar, I didn't import all the SWT classes, only the ones I needed: https://github.com/danlucraft/swt/blob/master/lib/swt/full.rb

I think you can get import into Ruby any other class you need like this:

module Swt
  module Widgets
    import org.eclipse.swt.widgets.Canvas
  end
end
talgorn commented 10 years ago

Works like a charm... :-)

Thank you very much for your quick and accurate reply !

Best,

danlucraft commented 10 years ago

No problem :)

If you add loads more classes I'll merge a pull request to import them too.

PragTob commented 10 years ago

Okay awesome then I believe we can close this issue and I have some classes to add from the shoes side probably :-)