SlideShare ist ein Scribd-Unternehmen logo
1 von 54
1 JRuby in Java Projects Denis Lutz
2 Motivation: Problem, Solution JRuby as language Java and Ruby Integration  Ruby Community Show Case Demo Usage areas for JRuby Agenda
3 Motivation
4 Lets redefine our thinking What is our task? What is the shortest path to the solution? Since
 Not the solving of complicated tasks is the goal 
but solving our task in the easiest possible way Motivation
5 Java has a huge set of tools JVM scripting languages are present (Groovy) You can find a tool for everything The java magazines are writing about scripting languages Theory
6 Projectwide scripting support not the rule, more an exception Ant = scripting language =>  XML is our scripting language If scripting language integration => Ant / Spring is the environment Adhoc scripting areas are randomly used by single devs Instead a major scripting support strategy is missing Young developers face only java or ant  Young devs are on their own to find more expressive languages Real world praxis
7 Entering JRuby
8 scripting tool as one of main and known tools scripting language as the surrounding environment and entry point (not Ant) clearly decleared scripting language standard definition of taks areas for the scripting language easy and powerfull communication with the underlying operating system powerfull language features instead of XML tools (Ant, Maven) knowledge reuse because of definition of several scripting areas in a projekt from GUIs and IDEs to automation and console procedures from enterprisy java community to a fun community in ruby Goal
9 What is JRuby ,[object Object]
Runs in JVM and integrates perfectly into Java environments
very expressive
mature
huge community powered by the Ruby on Rails framework,[object Object]
11 Facets of JRuby
12 Download Jruby at www.jruby.org Extract Add to  $PATH Test your installation with “jruby –v” on the console Command execution with “jruby –S ‘command’ ” jruby –S irb        -> Will start the JRuby console Get started with JRuby in 3 mins

13 Simple Syntax Everything is an object Blocks Self contained ( contains most useful libs out of the box) Open classes Principle of least surprise Most imressive language features
14 Simple object creation
15 Create your class and use it, lightweight and easy!
16 Everything is an object
17 Blocks, the most amazing and powerful feature ever
18 Lets call JRuby from Java public void callJRuby() {   ScriptEngineManager m = new ScriptEngineManager();  ScriptEngine rubyEngine = m.getEngineByName("jruby");  if (rubyEngine==null)       throw new RuntimeException("Did not find my ruby engine");  ScriptContext context = rubyEngine.getContext();  context.setAttribute("world","Programmierer",ScriptContext.ENGINE_SCOPE);  try{    File f = new File("hello1.rb");     BufferedReader br = new BufferedReader(new FileReader(f));     rubyEngine.eval(br, context); // (1)   } catch (ScriptException e) {   e.printStackTrace();   } catch (FileNotFoundException fnfe) {     System.err.println(fnfe.getMessage());   }}
19 require 'java’ java_import java.lang.System  => Java::JavaLang::System  version = System.getProperties["java.runtime.version"]  => "1.6.0_17-b04-248-10M3025”  import java.util.ArrayList list = ArrayList.new  => #<Java::JavaUtil::ArrayList:0x2bf09a31>  ruby-1.8.7-p334 :042 > iterator = list.iterator  => #<#<Class:01x41a7c484>:0x367c218e>  ruby-1.8.7-p334 :043 > iterator.java_class  => class java.util.AbstractList$Itr  ruby-1.8.7-p334 :044 > list.get(1) NativeException: java.lang.IndexOutOfBoundsException: Index: 1, Size: 0 Lets call Java from Jruby und use your legacy systems
20 Ruby’s Community
21 Very strong community, why? Got powered by Ruby on Rails (MVC Framework) Fun oriented community Motivated hobby programmers, who can be 9-5 employees ;-) Get into positive cycle of beeing threated well and wanting more ruby GEMS = ruby libraries, created by the community Community
22 Endless amounts of gems
23 Find most popular gems in one place, rated by the community
24 Live Demo: Using a GEM
25 we want to communicate with a REST API should be usable within a build or inside a java class of course Should provide an easy API for our java class The task Easiest solution (a base for it) ?
26 Choose your gem HTTParty Choose HTTParty as the gem for REST communication
27 Install the GEM
28 Write our nice little class
29 Use it immidiatelly on the console to play with it
30 We knew from one site about the best fitting GEM for our task We had no troubles installing it I can try my written code on the console it just works, doesn’t matter what you install its my experience after two years using ruby, yours will be the same Why was this great?
31 Integration with Java
32 Yes its right, Rails got over JSF (java standard) in the meanwhile Is this still a new and not known technology for you? Rails (Ruby) popularity
33 Yes, possible and widely used JRuby on Rails Frontend as war file in Tomcat Rails Front Ends in Java Projects possible  everything else is waste of money and developers frustration No risk, tell to your java influenced boss: „its just a war file“   No server infrastructure changes needed Deploy a Ruby on Rails Application in a java war jruby -S gem install -y rails warbler $RAILS_APP_ROOT/jruby -S warble war
34 Java Build with Rake
35 Rake as build tool in Java projects Basic problem: ANT is accepted, Maven the „new standard“ None of them is sufficient for the task we want to do Why?
36 Projectsetup, its in the Wiki, well because Ant cant do it ;-)  Folders and File management „if“ – „else“ , can you declare it out of your head now in Ant?   Declare a method in your build? Oh, yea no problem let me just look into Ant API Loading of fixtures, possible with some XML setup again Server startup? I am doing it by hand and each new developer has to learn the specifics  Maven „the biggest hype“ that helps me even less then Ant Problems with Ant and others

37 Full language power in your build, not XML We can still call our old Ant tasks UNIX operations as if we would be on the console Method declarations, as simple as possible Reuse of a language we already use not learning new XML frameworks What we want
38 Rake does all you want : project setup methods operating system calls objects in your build file operations Ivy integration Rake is the solution, rubys build tool
39 Rake in 3 mins, nothing is easier!
40 Call classic and custom Ant tasks from rake if needed
41 Operating system communication File management Folder management Talk to your operating system as from the console
42 Some rake possibilities = just full ruby power
43 In/Out API for your project
44 Its difficult to process files as well as different formats in java Import or Export is mostly a focused single task Can be done separated, by one developer No requirement to do it in java Customer data import is a very common and important task Use JRuby to provide an import / export API Data processing much faster Easy CSV, Excel, XML processing  Generate projects specific formats for import JRuby as your In/Out API of any project
45 JRuby as your In/Out API of any project
46 (Integration) Testing
47 Integration tests are the best candidate to do it with JRuby Abstract, mimal input, very high coverage Are easy to keep out of the java environment system Can be perfectly done with pure ruby WEBRAT GEM as JRuby Library Integration Testing
48 Webrat Example
49 GUI Testing API Evaluates the pure HTML output No browser setup or dependency to run your tests Write your tests fast in ruby  Cover the complete application workflow with minimal effort Can be run automatically in backgroud while developing Excellent to give fast feedback about application stability Webrat
50 Expected Result from  Jruby integration
51 All mentioned task areas can be done easier in JRuby More choices of tools, as would it be only with Java Knowledge reuse in different project areas Work is getting more lightweigt From java IDEs to fast editors Perfect interaction between different parts of the build Expected result

Weitere Àhnliche Inhalte

Was ist angesagt?

Mastering java bytecode with ASM - GeeCON 2012
Mastering java bytecode with ASM - GeeCON 2012Mastering java bytecode with ASM - GeeCON 2012
Mastering java bytecode with ASM - GeeCON 2012Anton Arhipov
 
TorqueBox - Ultrapassando a fronteira entre Java e Ruby
TorqueBox - Ultrapassando a fronteira entre Java e RubyTorqueBox - Ultrapassando a fronteira entre Java e Ruby
TorqueBox - Ultrapassando a fronteira entre Java e RubyBruno Oliveira
 
Mashups with Drupal and QueryPath
Mashups with Drupal and QueryPathMashups with Drupal and QueryPath
Mashups with Drupal and QueryPathMatt Butcher
 
Open Source Compiler Construction for the JVM
Open Source Compiler Construction for the JVMOpen Source Compiler Construction for the JVM
Open Source Compiler Construction for the JVMTom Lee
 
Java Bytecode For Discriminating Developers - GeeCON 2011
Java Bytecode For Discriminating Developers - GeeCON 2011Java Bytecode For Discriminating Developers - GeeCON 2011
Java Bytecode For Discriminating Developers - GeeCON 2011Anton Arhipov
 
Jruby synergy-of-ruby-and-java
Jruby synergy-of-ruby-and-javaJruby synergy-of-ruby-and-java
Jruby synergy-of-ruby-and-javaKeith Bennett
 
Java byte code & virtual machine
Java byte code & virtual machineJava byte code & virtual machine
Java byte code & virtual machineLaxman Puri
 
Introduction to the Java bytecode - So@t - 20130924
Introduction to the Java bytecode - So@t - 20130924Introduction to the Java bytecode - So@t - 20130924
Introduction to the Java bytecode - So@t - 20130924yohanbeschi
 
Beyond JVM - YOW! Sydney 2013
Beyond JVM - YOW! Sydney 2013Beyond JVM - YOW! Sydney 2013
Beyond JVM - YOW! Sydney 2013Charles Nutter
 
JavaScript Library Overview
JavaScript Library OverviewJavaScript Library Overview
JavaScript Library Overviewjeresig
 
Spring into rails
Spring into railsSpring into rails
Spring into railsHiro Asari
 
The Enterprise Strikes Back
The Enterprise Strikes BackThe Enterprise Strikes Back
The Enterprise Strikes BackBurke Libbey
 
Ruby on Rails survival guide of an aged Java developer
Ruby on Rails survival guide of an aged Java developerRuby on Rails survival guide of an aged Java developer
Ruby on Rails survival guide of an aged Java developergicappa
 
Seeking Clojure
Seeking ClojureSeeking Clojure
Seeking Clojurechrisriceuk
 
Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov
Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov
Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov Nayden Gochev
 
Introduction to Ruby on Rails
Introduction to Ruby on RailsIntroduction to Ruby on Rails
Introduction to Ruby on RailsAgnieszka Figiel
 
Java bytecode and classes
Java bytecode and classesJava bytecode and classes
Java bytecode and classesyoavwix
 

Was ist angesagt? (19)

Mastering java bytecode with ASM - GeeCON 2012
Mastering java bytecode with ASM - GeeCON 2012Mastering java bytecode with ASM - GeeCON 2012
Mastering java bytecode with ASM - GeeCON 2012
 
TorqueBox - Ultrapassando a fronteira entre Java e Ruby
TorqueBox - Ultrapassando a fronteira entre Java e RubyTorqueBox - Ultrapassando a fronteira entre Java e Ruby
TorqueBox - Ultrapassando a fronteira entre Java e Ruby
 
Mashups with Drupal and QueryPath
Mashups with Drupal and QueryPathMashups with Drupal and QueryPath
Mashups with Drupal and QueryPath
 
Open Source Compiler Construction for the JVM
Open Source Compiler Construction for the JVMOpen Source Compiler Construction for the JVM
Open Source Compiler Construction for the JVM
 
Java Bytecode For Discriminating Developers - GeeCON 2011
Java Bytecode For Discriminating Developers - GeeCON 2011Java Bytecode For Discriminating Developers - GeeCON 2011
Java Bytecode For Discriminating Developers - GeeCON 2011
 
Jruby synergy-of-ruby-and-java
Jruby synergy-of-ruby-and-javaJruby synergy-of-ruby-and-java
Jruby synergy-of-ruby-and-java
 
Java byte code & virtual machine
Java byte code & virtual machineJava byte code & virtual machine
Java byte code & virtual machine
 
Introduction to the Java bytecode - So@t - 20130924
Introduction to the Java bytecode - So@t - 20130924Introduction to the Java bytecode - So@t - 20130924
Introduction to the Java bytecode - So@t - 20130924
 
Beyond JVM - YOW! Sydney 2013
Beyond JVM - YOW! Sydney 2013Beyond JVM - YOW! Sydney 2013
Beyond JVM - YOW! Sydney 2013
 
JavaScript Library Overview
JavaScript Library OverviewJavaScript Library Overview
JavaScript Library Overview
 
Spring into rails
Spring into railsSpring into rails
Spring into rails
 
55 New Features in Java 7
55 New Features in Java 755 New Features in Java 7
55 New Features in Java 7
 
The Enterprise Strikes Back
The Enterprise Strikes BackThe Enterprise Strikes Back
The Enterprise Strikes Back
 
Ruby on Rails survival guide of an aged Java developer
Ruby on Rails survival guide of an aged Java developerRuby on Rails survival guide of an aged Java developer
Ruby on Rails survival guide of an aged Java developer
 
JVM
JVMJVM
JVM
 
Seeking Clojure
Seeking ClojureSeeking Clojure
Seeking Clojure
 
Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov
Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov
Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov
 
Introduction to Ruby on Rails
Introduction to Ruby on RailsIntroduction to Ruby on Rails
Introduction to Ruby on Rails
 
Java bytecode and classes
Java bytecode and classesJava bytecode and classes
Java bytecode and classes
 

Ähnlich wie JRuby in Java Projects

From Ant to Rake
From Ant to RakeFrom Ant to Rake
From Ant to Rakejazzman1980
 
Introduction to Java Programming, Basic Structure, variables Data type, input...
Introduction to Java Programming, Basic Structure, variables Data type, input...Introduction to Java Programming, Basic Structure, variables Data type, input...
Introduction to Java Programming, Basic Structure, variables Data type, input...Mr. Akaash
 
00 intro to java
00 intro to java00 intro to java
00 intro to javaDeia Abdullah
 
Bitter Java, Sweeten with JRuby
Bitter Java, Sweeten with JRubyBitter Java, Sweeten with JRuby
Bitter Java, Sweeten with JRubyBrian Sam-Bodden
 
Java Programming (M&M)
Java Programming (M&M)Java Programming (M&M)
Java Programming (M&M)mafffffe19
 
Elements of Java Language
Elements of Java Language Elements of Java Language
Elements of Java Language Hitesh-Java
 
Session 02 - Elements of Java Language
Session 02 - Elements of Java LanguageSession 02 - Elements of Java Language
Session 02 - Elements of Java LanguagePawanMM
 
Java presentation
Java presentationJava presentation
Java presentationKaran Sareen
 
Core Java Slides
Core Java SlidesCore Java Slides
Core Java SlidesVinit Vyas
 
Dynamic Languages on the JVM
Dynamic Languages on the JVMDynamic Languages on the JVM
Dynamic Languages on the JVMelliando dias
 
java new technology
java new technologyjava new technology
java new technologychavdagirimal
 
Programming in Java: Getting Started
Programming in Java: Getting StartedProgramming in Java: Getting Started
Programming in Java: Getting StartedMartin Chapman
 
JavaOne2015-What's in an Object?
JavaOne2015-What's in an Object?JavaOne2015-What's in an Object?
JavaOne2015-What's in an Object?Charlie Gracie
 
#JavaOne What's in an object?
#JavaOne What's in an object?#JavaOne What's in an object?
#JavaOne What's in an object?Charlie Gracie
 
EuRuKo JRuby Talk 2008
EuRuKo JRuby Talk 2008EuRuKo JRuby Talk 2008
EuRuKo JRuby Talk 2008geraldbauer
 
Java Programming Basics
Java Programming BasicsJava Programming Basics
Java Programming BasicsRkrishna Mishra
 
What is Java Technology (An introduction with comparision of .net coding)
What is Java Technology (An introduction with comparision of .net coding)What is Java Technology (An introduction with comparision of .net coding)
What is Java Technology (An introduction with comparision of .net coding)Shaharyar khan
 
Intoduction to java
Intoduction to javaIntoduction to java
Intoduction to javajalinder123
 
Dr. Rajeshree Khande :Intoduction to java
Dr. Rajeshree Khande :Intoduction to javaDr. Rajeshree Khande :Intoduction to java
Dr. Rajeshree Khande :Intoduction to javaDrRajeshreeKhande
 

Ähnlich wie JRuby in Java Projects (20)

From Ant to Rake
From Ant to RakeFrom Ant to Rake
From Ant to Rake
 
Introduction to Java Programming, Basic Structure, variables Data type, input...
Introduction to Java Programming, Basic Structure, variables Data type, input...Introduction to Java Programming, Basic Structure, variables Data type, input...
Introduction to Java Programming, Basic Structure, variables Data type, input...
 
00 intro to java
00 intro to java00 intro to java
00 intro to java
 
Bitter Java, Sweeten with JRuby
Bitter Java, Sweeten with JRubyBitter Java, Sweeten with JRuby
Bitter Java, Sweeten with JRuby
 
Java Programming (M&M)
Java Programming (M&M)Java Programming (M&M)
Java Programming (M&M)
 
Elements of Java Language
Elements of Java Language Elements of Java Language
Elements of Java Language
 
Session 02 - Elements of Java Language
Session 02 - Elements of Java LanguageSession 02 - Elements of Java Language
Session 02 - Elements of Java Language
 
Real World Technologies
Real World TechnologiesReal World Technologies
Real World Technologies
 
Java presentation
Java presentationJava presentation
Java presentation
 
Core Java Slides
Core Java SlidesCore Java Slides
Core Java Slides
 
Dynamic Languages on the JVM
Dynamic Languages on the JVMDynamic Languages on the JVM
Dynamic Languages on the JVM
 
java new technology
java new technologyjava new technology
java new technology
 
Programming in Java: Getting Started
Programming in Java: Getting StartedProgramming in Java: Getting Started
Programming in Java: Getting Started
 
JavaOne2015-What's in an Object?
JavaOne2015-What's in an Object?JavaOne2015-What's in an Object?
JavaOne2015-What's in an Object?
 
#JavaOne What's in an object?
#JavaOne What's in an object?#JavaOne What's in an object?
#JavaOne What's in an object?
 
EuRuKo JRuby Talk 2008
EuRuKo JRuby Talk 2008EuRuKo JRuby Talk 2008
EuRuKo JRuby Talk 2008
 
Java Programming Basics
Java Programming BasicsJava Programming Basics
Java Programming Basics
 
What is Java Technology (An introduction with comparision of .net coding)
What is Java Technology (An introduction with comparision of .net coding)What is Java Technology (An introduction with comparision of .net coding)
What is Java Technology (An introduction with comparision of .net coding)
 
Intoduction to java
Intoduction to javaIntoduction to java
Intoduction to java
 
Dr. Rajeshree Khande :Intoduction to java
Dr. Rajeshree Khande :Intoduction to javaDr. Rajeshree Khande :Intoduction to java
Dr. Rajeshree Khande :Intoduction to java
 

KĂŒrzlich hochgeladen

Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 

KĂŒrzlich hochgeladen (20)

Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 

JRuby in Java Projects

  • 1. 1 JRuby in Java Projects Denis Lutz
  • 2. 2 Motivation: Problem, Solution JRuby as language Java and Ruby Integration Ruby Community Show Case Demo Usage areas for JRuby Agenda
  • 4. 4 Lets redefine our thinking What is our task? What is the shortest path to the solution? Since
 Not the solving of complicated tasks is the goal 
but solving our task in the easiest possible way Motivation
  • 5. 5 Java has a huge set of tools JVM scripting languages are present (Groovy) You can find a tool for everything The java magazines are writing about scripting languages Theory
  • 6. 6 Projectwide scripting support not the rule, more an exception Ant = scripting language => XML is our scripting language If scripting language integration => Ant / Spring is the environment Adhoc scripting areas are randomly used by single devs Instead a major scripting support strategy is missing Young developers face only java or ant Young devs are on their own to find more expressive languages Real world praxis
  • 8. 8 scripting tool as one of main and known tools scripting language as the surrounding environment and entry point (not Ant) clearly decleared scripting language standard definition of taks areas for the scripting language easy and powerfull communication with the underlying operating system powerfull language features instead of XML tools (Ant, Maven) knowledge reuse because of definition of several scripting areas in a projekt from GUIs and IDEs to automation and console procedures from enterprisy java community to a fun community in ruby Goal
  • 9.
  • 10. Runs in JVM and integrates perfectly into Java environments
  • 13.
  • 14. 11 Facets of JRuby
  • 15. 12 Download Jruby at www.jruby.org Extract Add to $PATH Test your installation with “jruby –v” on the console Command execution with “jruby –S ‘command’ ” jruby –S irb -> Will start the JRuby console Get started with JRuby in 3 mins

  • 16. 13 Simple Syntax Everything is an object Blocks Self contained ( contains most useful libs out of the box) Open classes Principle of least surprise Most imressive language features
  • 17. 14 Simple object creation
  • 18. 15 Create your class and use it, lightweight and easy!
  • 19. 16 Everything is an object
  • 20. 17 Blocks, the most amazing and powerful feature ever
  • 21. 18 Lets call JRuby from Java public void callJRuby() { ScriptEngineManager m = new ScriptEngineManager(); ScriptEngine rubyEngine = m.getEngineByName("jruby"); if (rubyEngine==null) throw new RuntimeException("Did not find my ruby engine"); ScriptContext context = rubyEngine.getContext(); context.setAttribute("world","Programmierer",ScriptContext.ENGINE_SCOPE); try{ File f = new File("hello1.rb"); BufferedReader br = new BufferedReader(new FileReader(f)); rubyEngine.eval(br, context); // (1) } catch (ScriptException e) { e.printStackTrace(); } catch (FileNotFoundException fnfe) { System.err.println(fnfe.getMessage()); }}
  • 22. 19 require 'java’ java_import java.lang.System => Java::JavaLang::System version = System.getProperties["java.runtime.version"] => "1.6.0_17-b04-248-10M3025” import java.util.ArrayList list = ArrayList.new => #<Java::JavaUtil::ArrayList:0x2bf09a31> ruby-1.8.7-p334 :042 > iterator = list.iterator => #<#<Class:01x41a7c484>:0x367c218e> ruby-1.8.7-p334 :043 > iterator.java_class => class java.util.AbstractList$Itr ruby-1.8.7-p334 :044 > list.get(1) NativeException: java.lang.IndexOutOfBoundsException: Index: 1, Size: 0 Lets call Java from Jruby und use your legacy systems
  • 24. 21 Very strong community, why? Got powered by Ruby on Rails (MVC Framework) Fun oriented community Motivated hobby programmers, who can be 9-5 employees ;-) Get into positive cycle of beeing threated well and wanting more ruby GEMS = ruby libraries, created by the community Community
  • 26. 23 Find most popular gems in one place, rated by the community
  • 27. 24 Live Demo: Using a GEM
  • 28. 25 we want to communicate with a REST API should be usable within a build or inside a java class of course Should provide an easy API for our java class The task Easiest solution (a base for it) ?
  • 29. 26 Choose your gem HTTParty Choose HTTParty as the gem for REST communication
  • 31. 28 Write our nice little class
  • 32. 29 Use it immidiatelly on the console to play with it
  • 33. 30 We knew from one site about the best fitting GEM for our task We had no troubles installing it I can try my written code on the console it just works, doesn’t matter what you install its my experience after two years using ruby, yours will be the same Why was this great?
  • 35. 32 Yes its right, Rails got over JSF (java standard) in the meanwhile Is this still a new and not known technology for you? Rails (Ruby) popularity
  • 36. 33 Yes, possible and widely used JRuby on Rails Frontend as war file in Tomcat Rails Front Ends in Java Projects possible everything else is waste of money and developers frustration No risk, tell to your java influenced boss: „its just a war file“  No server infrastructure changes needed Deploy a Ruby on Rails Application in a java war jruby -S gem install -y rails warbler $RAILS_APP_ROOT/jruby -S warble war
  • 37. 34 Java Build with Rake
  • 38. 35 Rake as build tool in Java projects Basic problem: ANT is accepted, Maven the „new standard“ None of them is sufficient for the task we want to do Why?
  • 39. 36 Projectsetup, its in the Wiki, well because Ant cant do it ;-) Folders and File management „if“ – „else“ , can you declare it out of your head now in Ant? Declare a method in your build? Oh, yea no problem let me just look into Ant API Loading of fixtures, possible with some XML setup again Server startup? I am doing it by hand and each new developer has to learn the specifics Maven „the biggest hype“ that helps me even less then Ant Problems with Ant and others

  • 40. 37 Full language power in your build, not XML We can still call our old Ant tasks UNIX operations as if we would be on the console Method declarations, as simple as possible Reuse of a language we already use not learning new XML frameworks What we want
  • 41. 38 Rake does all you want : project setup methods operating system calls objects in your build file operations Ivy integration Rake is the solution, rubys build tool
  • 42. 39 Rake in 3 mins, nothing is easier!
  • 43. 40 Call classic and custom Ant tasks from rake if needed
  • 44. 41 Operating system communication File management Folder management Talk to your operating system as from the console
  • 45. 42 Some rake possibilities = just full ruby power
  • 46. 43 In/Out API for your project
  • 47. 44 Its difficult to process files as well as different formats in java Import or Export is mostly a focused single task Can be done separated, by one developer No requirement to do it in java Customer data import is a very common and important task Use JRuby to provide an import / export API Data processing much faster Easy CSV, Excel, XML processing Generate projects specific formats for import JRuby as your In/Out API of any project
  • 48. 45 JRuby as your In/Out API of any project
  • 50. 47 Integration tests are the best candidate to do it with JRuby Abstract, mimal input, very high coverage Are easy to keep out of the java environment system Can be perfectly done with pure ruby WEBRAT GEM as JRuby Library Integration Testing
  • 52. 49 GUI Testing API Evaluates the pure HTML output No browser setup or dependency to run your tests Write your tests fast in ruby Cover the complete application workflow with minimal effort Can be run automatically in backgroud while developing Excellent to give fast feedback about application stability Webrat
  • 53. 50 Expected Result from Jruby integration
  • 54. 51 All mentioned task areas can be done easier in JRuby More choices of tools, as would it be only with Java Knowledge reuse in different project areas Work is getting more lightweigt From java IDEs to fast editors Perfect interaction between different parts of the build Expected result
  • 55. 52 My personal, subjective impression You will reach more, having to know less Achieve more with less work using ruby
  • 56. 53 http://www.jruby.org/ http://kenai.com/projects/jruby/pages/Home Jruby console with “jruby –S irb” http://www.cygwin.com/ (Unix Console replacement for Windows) Editors Textmate (MacOs) http://www.e-texteditor.com/ (Windows) IDE’s http://www.jetbrains.com/ruby/ http://www.aptana.com/products/radrails (Eclipse Plugin) http://wiki.netbeans.org/Ruby (Netbeans Ruby Support) Further informations
  • 57. 54 Thanks a lot and have fun with JRuby!