Questions tagged [jruby-java-interop]

32 questions
2
votes
1 answer

Difference between jruby AOT classes with --java flag and without

When I compile a ruby file to a java class using jrubyc, I get different output when compiling with just jrubyc and with jrubyc --java (to generate the java file) and just javac. Why? Example: First method: jrubyc --java myscript.rb javac -cp…
Johnathan Leppert
  • 365
  • 1
  • 5
  • 11
1
vote
1 answer

jruby does not understand import statement

I'm converting a project written with JRuby 1.7 in mind to JRuby 9.4. One of the files starts like this: if RUBY_PLATFORM == 'java' require 'java' import java.lang.management.ManagementFactory .... end The import does not work anymore.…
user1934428
  • 19,864
  • 7
  • 42
  • 87
1
vote
1 answer

Access enums from Jar file in Jruby

I'm trying to access the following static enum public class Colors { public enum ListofColors { BLUE, RED, YELLOW } } But I keep getting the error NameError: cannot load Java class Colors.Colors::ListofColors::BLUE When I try…
hello_its_me
  • 743
  • 2
  • 19
  • 52
1
vote
2 answers

How do I use JRuby and Java?

Is that feature still supported? I can't seem to find any Documentation past 2008 or so. This is an insert from the Oracle website... At runtime, the JSR 223 Scripting APIs must locate the appropriate script engine for the scripting language you…
1
vote
0 answers

Same process id for exec in ruby script

Is there anyone know the implementation of exec by JRuby implementation. I have two simple rubys scripts: Test.rb calls another called.rb via exec, as below: //Test.rb #!/usr/bin/env jruby sleep 10 puts "hello 1 " exec "./called.rb" puts "hello…
shijie xu
  • 1,975
  • 21
  • 52
1
vote
1 answer

import java class in JRuby

I am trying to import a Java Class in Jruby $ ls bin src $ ls bin/com/practice Test.class $ ls src/com/practice Test.java $ cat src/com/practice/Test.java package com.practice; public class Test { public static String foo(){ return…
CuriousMind
  • 33,537
  • 28
  • 98
  • 137
1
vote
1 answer

__persistence__ NoMethodError

I'm mocking a java interface in rspec clock = ClockInterface.new clock.should_receive(:currentTime) When I run rspec everything works fine but I see a warning which directs me to the following https://github.com/jruby/jruby/wiki/Persistence When I…
Gregory Ostermayr
  • 1,123
  • 10
  • 17
1
vote
0 answers

How to load, compile, and call a JRuby file, from Java?

The best doc I found was this, but it's a bit outdated -- deprecated or missing methods. I'd like to, from Java code: Load a .rb file from the filesystem. Make sure it is compiled to the fastest form possible, since this exists in a long-running…
Rob N
  • 15,024
  • 17
  • 92
  • 165
0
votes
2 answers

Use gems with c-extensions in JRuby, or port them to Java?

I'm doing a fuzzy match test between an input string and some previously entered strings. The test is performed live while typing. I already have a shockingly accurate algorithm in place called StrikeAMatch, which has been translated into many…
Cjoerg
  • 1,271
  • 3
  • 21
  • 63
0
votes
1 answer

JRuby file not run when executing from jar file (was: System.out.println not working from jar file)

(Crossposted at JRuby Forum, but posted here again because I did not get any answer yet). Platform: jruby 9.0.4.0 (2.2.2) 2015-11-12 b9fb7aa Java HotSpot(TM) 64-Bit Server VM 24.79-b02 on 1.7.0_79-b15 +jit [Windows 7-amd64] Main program in Java,…
user1934428
  • 19,864
  • 7
  • 42
  • 87
0
votes
1 answer

JRuby proc as a Java interface implementation

My question is related to closure conversion. I want to test a proc that implements a functional interface from jruby code. I have a simple proc like proc { print 'hey!' } to implement a java functional interface like public void doStuff() Since…
Samuel García
  • 2,199
  • 14
  • 21
0
votes
1 answer

Debugging between JRuby and Java

I have a large Java project that uses some Ruby scripts (primarily because of Ruby's support for "yield"). The Ruby code calls Java code which calls more Ruby code. It's very interleaved, but everything is driven from Java. I'm using embedded…
Jon O
  • 6,532
  • 1
  • 46
  • 57
0
votes
2 answers

Search for a pattern in a file and print it in jruby

I have a file with n number of lines. I need to search for a field(SessionId and its value) in it and print its corresponding value. I have coded to access the file and print it line by line. Need help in getting a field and printing its…
karthick23
  • 1,313
  • 1
  • 8
  • 15
0
votes
1 answer

How can I define a Java interface in JRuby rather than implement one?

I would like to invoke a Java API from JRuby that requires a Java interface, not a concrete class. The Java API uses java.lang.reflect.proxy to implement functionality based on the interface. I have found numerous examples of implementing a java…
Todd Stout
  • 3,687
  • 3
  • 24
  • 29
0
votes
1 answer

org.jruby.embed.EvalFailedException: (LoadError) no such file to load

I've created jar file from ruby code using warbler. File structure within jar is as below: core.jar ----core --------lib ------------gui.class ------------gui.rb I've other java application from which I want to run "connect" function which is in Gui…
Keyur Shah
  • 81
  • 1
  • 6