Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NameError: uninitialized constant Swt #9

Open
DouglasAllen opened this issue Sep 12, 2013 · 6 comments
Open

NameError: uninitialized constant Swt #9

DouglasAllen opened this issue Sep 12, 2013 · 6 comments

Comments

@DouglasAllen
Copy link

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
Copy link
Collaborator

PragTob commented Sep 12, 2013

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
Copy link

talgorn commented Sep 18, 2013

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
Copy link
Owner

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
Copy link

talgorn commented Sep 18, 2013

Works like a charm... :-)

Thank you very much for your quick and accurate reply !

Best,

@danlucraft
Copy link
Owner

No problem :)

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

@PragTob
Copy link
Collaborator

PragTob commented Sep 19, 2013

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants