Such as Map, List etc.
Thanks
Such as Map, List etc.
Thanks
You can reference a Java class in JRuby in at least two different ways.
The first is to map Java names like org.foo.department.Widget to Ruby
nested modules format. This works as follows:
Java: org.foo.department.Widget
Ruby: Java::OrgFooDepartment::Widget
Second way: for the top-level Java packages java, javax, org, and com
you can type in a fully qualified class name basically as in Java,
for example, java.lang.System or org.abc.def.ClassName
With the java_import statement, you can access the Java class via a
constant that java_import creates for you in the current namespace.
A random example:
require "java"
include_class "java.util.ArrayList"
arrlist = ArrayList.new
arrlist.add "Amit"
arrlist.add "Kumar"
arrlist.add "Vineet"
puts "#{arrlist}"
On 1/20/22, Adriel Peng <peng.adriel@gmail.com> wrote:
[can JRuby read java's data structure] Such as Map, List etc.
That's right, thanks Frank. My purpose is to check if I can read data from
the backend service (big data part) and have the results presented in the
front-end via web interface by Ruby.
Kind regards,
Adriel
On Fri, Jan 21, 2022 at 10:23 PM Frank J. Cameron <fjc@fastmail.net> wrote:
On 1/20/22, Adriel Peng <peng.adriel@gmail.com> wrote:
> [can JRuby read java's data structure] Such as Map, List etc.You can reference a Java class in JRuby in at least two different ways.
The first is to map Java names like org.foo.department.Widget to Ruby
nested modules format. This works as follows:Java: org.foo.department.Widget
Ruby: Java::OrgFooDepartment::WidgetSecond way: for the top-level Java packages java, javax, org, and com
you can type in a fully qualified class name basically as in Java,
for example, java.lang.System or org.abc.def.ClassNameWith the java_import statement, you can access the Java class via a
constant that java_import creates for you in the current namespace.CallingJavaFromJRuby · jruby/jruby Wiki · GitHub
A random example:
require "java"
include_class "java.util.ArrayList"
arrlist = ArrayList.new
arrlist.add "Amit"
arrlist.add "Kumar"
arrlist.add "Vineet"
puts "#{arrlist}"Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>
Hi Adriel,
That's right, thanks Frank. My purpose is to check if I can read data from the backend service (big data part) and have the results presented in the front-end via web interface by Ruby.
In short, yes - that should be very much possible.
I have an example of using a Java library (Apache POI) from Ruby code running on JRuby on my site here:
Also, the JRuby community is very helpful (as is the Ruby community) - so, you'll be able to get help once you start to get clearer on what you want to achieve.
Best Regards,
Mohit.
On 2022-1-22 8:08 am, Adriel Peng wrote:
--
Mohit Sindhwani
W: notepad.onghu.com
Tw: @onghu