Re: Java, Ruby, JRuby, JRubify some Java?

-------- Original-Nachricht --------
Datum: Wed, 23 Sep 2009 15:25:11 +0900
Von: Audrey A Lee <>
An: ruby-talk@xxxxxxxxxxxxx
Betreff: Java, Ruby, JRuby, JRubify some Java?

Hello JRuby People,

I'm not quite ready to JRubyify yet but,
I'm working on a mini-project which requires that I screen-capture a
portion of my x-display on a linux box.

It looks like I can use a class in Java named "Robot" to do this:

I figure any class (even if it is a Java class) named "Robot" deserves
my attention.

So I ran this query:

And this page looks good:

I see this example:

import java.awt.AWTException;
import java.awt.Robot;
import java.awt.Rectangle;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import javax.imageio.ImageIO;

class ScreenCapture {
public static void main(String args[]) throws
AWTException, IOException {
// capture the whole screen
BufferedImage screencapture = new Robot().createScreenCapture(
new Rectangle(Toolkit.getDefaultToolkit().getScreenSize
()) );

// Save as JPEG
File file = new File("screencapture.jpg");
ImageIO.write(screencapture, "jpg", file);

// Save as PNG
// File file = new File("screencapture.png");
// ImageIO.write(screencapture, "png", file);

My question:
Is it possible to transform the above Java-syntax into Ruby-syntax
which could be interpreted by JRuby?

Or I could ask it this way:
How do I transform the above Java-syntax into JRuby-syntax?


Dear Audrey,

you can use Java classes in Jruby straight away:

For Linux automation, you might want to look at (the non-Java)
xdotool and its Ruby gem binding xdo:

You might combine that with one of the many ways to take screenshots
in Linux:

Best regards,


GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
Jetzt freischalten unter


Relevant Pages