This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
JS = Java::java.lang.System | |
os = JS.get_property 'os.name' | |
home = JS.get_property 'java.home' | |
mem = Java::java.lang.Runtime.get_runtime.free_memory | |
puts "Running on #{os}" | |
puts "Java home is #{home}" | |
puts "#{mem} bytes available in JVM" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'java' | |
#java_import 'java.util.Date' | |
java_import('java.util.Date') { |pkg,name| 'JDate' } | |
java_import 'java.text.DateFormat' | |
date = JDate.new | |
date_format = DateFormat.get_date_instance | |
date_us = date_format .format date | |
puts date_us |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.*; | |
public class InternationalizationEx | |
{ | |
public static void main(String[] args) | |
{ | |
String lang, country; | |
Locale cLocale; | |
ResourceBundle msg; | |
lang = new String("de"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
D:\elasticsearch-0.17.6\bin>elasticsearch.bat | |
"C:\Program Files\Java\jdk1.6.0_26\bin\java" -Xms256m -Xmx1g -Xss128k -XX:+UseP | |
arNewGC -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -XX:SurvivorRatio= | |
8 -XX:MaxTenuringThreshold=1 -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSIn | |
itiatingOccupancyOnly -XX:+HeapDumpOnOutOfMemoryError -Delasticsearch -Des-fore | |
ground=yes -Des.path.home="D:\elasticsearch-0.17.6" -cp ";.;D:\apache-solr-3.3.0 | |
\dist\apache-solr-solrj-3.3.0.jar;D:\apache-solr-3.3.0\example\work\Jetty_0_0_0_ | |
0_8983_solr.war__solr__k1kf17\webapp\WEB-INF\lib\slf4j-jdk14-1.6.1.jar;D:\apache | |
-solr-3.3.0\dist\solrj-lib\commons-codec-1.4.jar;D:\apache-solr-3.3.0\dist\solrj | |
-lib\commons-httpclient-3.1.jar;D:\apache-solr-3.3.0\dist\solrj-lib\commons-io-1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 1 | |
class Rubyist | |
def self.who | |
"Geek" | |
end | |
end | |
puts Rubyist.who | |
# 2 | |
class Rubyist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "rubygems" | |
require "bundler/setup" | |
require "sinatra" | |
get '/hi' do | |
"Hello JRuby World!" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'open-uri' | |
require 'csv' | |
unless ARGV.length == 1 | |
puts "Usage: jruby09.rb INTC" | |
exit | |
end | |
url = "http://download.finance.yahoo.com/d/quotes.csv?s=#{ARGV[0]}&f=snl1d1t1c1ohgv&e=.csv" | |
csv = CSV.parse(open(url).read) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "rubygems" | |
require "bundler/setup" | |
require 'zip/zip' | |
# Hard-coding the file names | |
file = "jruby-complete.jar" | |
zip = "zip.zip" | |
if File.exists?(file) | |
#Create a Zip object to put compressed data in | |
Zip::ZipFile.open(zip, true) do |zipfile| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
directory 'vendor' | |
desc 'Install Ruby gems into vendor/' | |
task :install_gems => 'vendor' do | |
sh 'jruby -S gem install -i vendor rubyzip' | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.jruby.embed.ScriptingContainer; | |
public class JavaLauncher { | |
public static void main(String[] args) { | |
ScriptingContainer container = new ScriptingContainer(); | |
container.runScriptlet("require 'compress'"); | |
} | |
} |