Skip to content

Instantly share code, notes, and snippets.

Java in Ruby: Scripting Java in JRuby
One major benefit of JRuby is the ability to import Java classes and then use them as if they were POROs (Plain Old Ruby Objects). This feature makes Java fun again. You can pull in legacy code and sculpt an API which fits nicely into your Ruby code. You can access novel or robust Java libraries to bridge a gap in existing Ruby libraries.
This talk will:
* Show basics of interacting with Java classes from within Ruby
* Implementing Java interfaces with Ruby blocks and classes
* Point out Gotchas
* Give style hints to make Java APIs fit better into the Ruby way
16:15:00 /c/opt/jruby.cygwin $ ./bin/jruby -rjruby -e 'p JRuby.runtime.posix.aspawn(false, nil, [\"dir\", \"/?\"])'
COMMAND: C:\Windows\system32\cmd.exe /c dir /?, SHELL: C:\Windows\system32\cmd.exe
Program: C:\Windows\system32\cmd.exe, COMMAND: C:\Windows\system32\cmd.exe /c dir /?
RV: true
3704
Displays a list of files and subdirectories in a directory.
[WARNING]
[WARNING] Some problems were encountered while building the effective settings
[WARNING] expected START_TAG or END_TAG not TEXT (position: TEXT seen ... http://maven.apache.org/xsd/settings-1.0.0.xsd">\n ...\n <s... @6:5) @ /Users/enebo/.m2/settings.xml, line 6, column 5
[WARNING]
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for jline:jline:jar:1.0
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-compiler-plugin is missing. @ line 115, column 15
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-surefire-plugin is missing. @ line 107, column 15
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-site-plugin is missing. @ line 123, column 15
JRuby 1.6.1 Released
Tuesday, April 12 2011
The JRuby community is pleased to announce the release of JRuby 1.6.1.
* Homepage: http://www.jruby.org/
* Download: http://www.jruby.org/download
JRuby 1.6.1 is our first update to 1.6.0. The primary goal of the 1.6.x series is to round out our 1.9 support by fixing any reported incompatibilities. Of course, as with any JRuby release, we will continue fixing any found incompatibilities and also improve performance. All users of 1.6.0 (and lower) are encouraged to upgrade to 1.6.1.
Notable Changes:
class WeatherPlugin
include Prugin::Plugin
def on_enable
event(:weather_change) { |e| e.cancelled = true if e.to_weather_state }
event(:thunder_change) { |e| e.cancelled = true if e.to_thunder_state }
event(:lightning_strike) { |e| e.cancelled = true }
event(:world_load) do |e|
server.worlds.each do |world|
world.storm = false if world.hasStorm
diff --git a/spec/java_integration/fixtures/MethodNames.java b/spec/java_integration/fixtures/MethodNames.java
index 9366424..b86b77f 100644
--- a/spec/java_integration/fixtures/MethodNames.java
+++ b/spec/java_integration/fixtures/MethodNames.java
@@ -23,7 +23,7 @@ public class MethodNames {
public static boolean hasThird1() {return false;}
public static boolean hasFourth1(Object something) {return false;}
public static String __send__() { return "foo"; }
-
+
require 'java'
import java.io.StringReader
import org.jrubyparser.Parser
import org.jrubyparser.parser.ParserConfiguration
import org.jrubyparser.CompatVersion
$parser = Parser.new
$config = ParserConfiguration.new
$config_1_9 = ParserConfiguration.new(0, CompatVersion::RUBY1_9)
# encoding: UTF-8
def 前提(a)
yield a
end
前提 "を入力" do |n|
puts n
end
The JRuby community is pleased to announce the release of JRuby 1.6.2.
Homepage: http://www.jruby.org/
Download: http://www.jruby.org/download
JRuby 1.6.2 is our second update to 1.6.x. The main motivation besides spinning incremental releases quicker was a nasty YAML bug which prevented a number of Rubygems from installing (see JRUBY-5581 -- ArrayIndexOutOfBounds problem). Expect JRuby 1.6.3 in a couple of weeks.
The primary goal of the 1.6.x series is to round out our 1.9 support by fixing any reported incompatibilities. Of course, as with any JRuby release, we will continue fixing any found incompatibilities and also improve performance. All users of 1.6.1 (and lower) are encouraged to upgrade to 1.6.2.
Notable:
@enebo
enebo / gist:1004749
Created June 2, 2011 16:29
-Xbacktrace.style=raw can be nice
=> Booting WEBrick
=> Rails 3.0.7 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2011-06-02 11:28:31] INFO WEBrick 1.3.1
[2011-06-02 11:28:31] INFO ruby 1.8.7 (2011-05-31) [java]
[2011-06-02 11:28:35] INFO WEBrick::HTTPServer#start: pid=81165 port=3000
[2011-06-02 11:28:39] ERROR NoMethodError: undefined method `sub' for nil:NilClass
java/lang/Thread.java:1503:in `getStackTrace'
org/jruby/runtime/backtrace/TraceType.java:48:in `getBacktraceData'