arton / rjb

Ruby Java Bridge
https://www.artonx.org/collabo/backyard/?RubyJavaBridge
GNU Lesser General Public License v2.1
117 stars 34 forks source link

Apple AWT Java VM was loaded on first thread -- can't start AWT(on mac OSX) #38

Closed dineshperomy closed 9 years ago

dineshperomy commented 9 years ago

Hello,

In my test ,I am trying to import java sikuli class from Java into Ruby through rjb configuration but the system throws an error as like as follows..

2015-11-05 10:12:29.066 ruby[24107:756077] Apple AWT Java VM was loaded on first thread -- can't start AWT. /Users/xxxxxx/Desktop/Test_BDD/features/step_definitions/test.rb:7:in new': Can't start the AWT because Java was started on the first thread. Make sure StartOnFirstThread is not specified in your application's Info.plist or on the command line (InternalError) from /Users/xxxxxxx/Desktop/Test_BDD/features/step_definitions/test.rb:7:in<top (required)>' from -e:1:in load' from -e:1:in

'

Sample code Used: require 'rjb' require 'rubygems' Rjb::load('/Users/xxxxxx/Desktop/Test_BDD/features/lib/sikulixapi.jar', []) Screen=Rjb::import('org.sikuli.script.Screen') screen =Screen.new screen.click(10,10)

Machine Details: OS: Mac OSX(Yosemite) version (10.10.4 ) IDE: Rubymine

Please help me out sort out this issue as early as possible

arton commented 9 years ago

Hi,

Apple AWT is very Rjb unfriendly because its thread handling is very strange. There is a chance that you require, load and call AWT object in other thread than main. For example:

t = Thread.new require 'rjb' .... end t.join

However, I'm not sure above code runs or not.

Regards

dineshperomy commented 9 years ago

Thanks for you input.But now I am not getting an error related to AWT but nothing is happening. The scripts keeps running...

Here is how I have used.

t = Thread.new { require 'rjb' require 'rubygems' Rjb::load('/Users/xxxxx/Desktop/Test_BDD/features/lib/sikuli-java.jar', []) Screen=Rjb::import('org.sikuli.script.Screen') screen =Screen.new image=screen.find('/Users/xxxx/Desktop/Test_BDD/features/lib/testImage.png') screen.click(image) } t.join

Output: The scripts keeps running without any output

Appreciate any support over here