# Call Java with JRuby

**URL:** <https://www.ruby-forum.com/t/call-java-with-jruby/167031>\
**Category:** JRuby\
**Created:** [May 2, 2009, 2:21pm UTC](https://www.ruby-forum.com/t/call-java-with-jruby/167031 "2009-05-02T14:21:04Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dynamic84](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/8c91f0/32.png) [@dynamic84](https://www.ruby-forum.com/u/dynamic84)\
**Post date:** [May 2, 2009, 2:21pm UTC](https://www.ruby-forum.com/t/call-java-with-jruby/167031/1 "2009-05-02T14:21:04Z")

</div>

Hi,

I am a problem for my project at University…  
the using:

JRuby =\> 1.8.6  
Rails =\> 2.3.2  
Java =\> JDK 1.6 and MySql 5.06

The Call java in Jruby is correct:

- configuration the file jar  
Open File Configuration/environment.rb

\*\*\* And i added in this file  
require ‘rubygems’  
gem ‘activerecord-jdbc-adapter’  
require ‘jdbc\_adapter’  
include Java

\*\*\* in the controller implements the costruct Java  
import “java.post.PostInformation”  
import “java.post.PostManagement”  
class Post  
def attibute  
@title = post\_info.setTitle(" “)  
@description = post\_info.setDescription(” ")  
end

def create  
@post\_info = PostInformation.new  
@post\_mgm = PostManagement.new  
post\_mgm.addPost(attribute)  
end

In the model  
class Post

#Question: define the methods for views, it’s a correct???

def title  
@post\_info = PostInformation.new  
post\_info.setTitle(" ")  
end

View

# New post

\<% form\_tag :controller =\> ‘posts’, :active =\> ‘create’ do %\>

\<%= label\_tag :title %\>  
 \<%= text\_field\_tag :title %\>

\<%= label\_tag :description %\>  
 \<%= text\_area\_tag :description %\>

\<%= submit\_tag 'Create' %\>

\<% end %\>

sorry for my English … 😛

Thanks  
Daniel
