Project

bind-it

0.02
No commit activity in last 3 years
No release in over 3 years
There's a lot of open issues
BindIt is a thin wrapper over the Ruby-Java-Bridge (Rjb) to facilitate the creation of Java bindings in Ruby.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

~> 1.4.3
 Project Readme

About

BindIt is a tool that allows to build platform-agnostic Ruby wrappers for JAVA code. The resulting bindings will work both on the JRuby and MRI platforms. On the MRI platform, BindIt uses the Ruby-Java-Bridge (Rjb) to access Java objects.

BindIt is tested on MRI Ruby 1.9.2 and 1.9.3, as well as JRuby 1.6.7.2 and 1.7.1.

Installing

gem install bind-it

Usage

  1. Create a module into which Java classes will be loaded.
  2. Make sure that module extends BindIt::Binding.
  3. Set your configuration options (see examples below).
  4. Run YourModule.bind to load the default JARs and classes.
  5. Access loaded Java classes using YourModule::YourClass.

Example

require 'bind-it'

module MyBindings 

  extend BindIt::Binding

  # Arguments to use when initializing the JVM.
  self.jvm_args = ['-option1X', '-option2X']

  # If set, JVM output is redirected to file.
  self.log_file = 'log_file.txt'

  # The path in which to look for JAR files.
  self.jar_path = '/path/to/jars/'

  # Default JAR files to load.
  self.default_jars = [
    'jar1.jar',
    'jar2.jar'
  ]

  # Default namespace to use when loading classes.
  self.default_namespace = 'path.to.default'

  # Default classes to load under MyBindings.
  # Shown are the three different ways of adding
  # a class to the default list.
  self.default_classes = [
     # Will search for class in default_namespace.
     ['MyClass'],
     # Supply a non-default namespace.
     ['MyClass', 'path.to.namespace']
  ]

  # Load the default JARs and classes.
  self.bind

end

obj = MyBindings::MyClass.new

Contributing

Feel free to fork the project and send me a pull request!