I love JRuby

Really, I love JRuby.

report = JasperCompileManager.compileReport( "myreport.jrxml" ) 
ds = RDataProvider.new( "mydata.csv" )
File.open( "myreport.pdf", "w" ) do |f|
  pdf = JasperRunManager.runReportToPdf( report,  nil, ds )
  out_str = String.from_java_bytes( pdf )
  f.write( out_str )
end

And that’s about it. This is almost all that is required to generate a PDF file for a given report from data stored in a CSV file, using the Java libraries from JasperReports and JRuby.

One Response to “I love JRuby”

  1. Recent Links Tagged With "jruby" - JabberTags Says:

    [...] ruby-plsql gem now supports JRuby and Oracle JDBC driver Saved by jaymun on Wed 10-12-2008 I love JRuby Saved by XxanimefreekxX on Sat 06-12-2008 Installing JRuby and JRuby on Rails with MySQL Saved by [...]