How to load/use a 3rd party jar file

Hi everyone.

I’m trying to figure out how to use a third party jar file in my Jruby
app.

In java it looks like

import com.mycompany.metadata.*
jmdConnection ci = new jmdConnection();

In ruby I’m trying to do the following, but it doesn’t work. Can anyone
help.

require ‘lib/metadata.jar’

class API
include_package com.mycompany.metadata
end

ci = jmdConnection.new()


View this message in context:
http://www.nabble.com/How-to-load-use-a-3rd-party-jar-file.-tp19745520p19745520.html
Sent from the JRuby - User mailing list archive at Nabble.com.


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

I finally got it to work. Here’s a piece of the solution I used in case
anyone is curious.

require ‘java’

module MetadataAPI
require ‘lib/metadata.jar’

Md_Connection = com.mycompany.metadata.jmdConnection
Md_Jmd = com.mycompany.metadata.jmd
Md_LongField = com.mycompany.metadata.jmdLongField
end

class MetadataQuery
include MetadataAPI

def initialize
@connected = false
@ci = Md_Connection.new()
@ci.InitMem() #some quirky thing the API requires.
end

def connect
end
end