Permalink
Browse files

Updated examples with new Main.java, jar references

  • Loading branch information...
1 parent d9be61a commit d4f2fe66aaed7f24accb24d4d077458236647ce6 @Neurogami Neurogami committed Oct 26, 2011
@@ -1 +1,14 @@
Place your jars here.
+
+You'll need current versions of:
+
+* monkeybars
+* jruby-complete
+
+These would ordinarily be installed when you generated a project,
+but since this is a given example the jars are omitted to avoid
+bloating the source distribution.
+
+
+You might also need a miglayout jar, but this is an older example that may be using swinglayout
+
@@ -1,51 +1,55 @@
-package org.rubyforge.rawr;
+package com.neurogami.rawr;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
import java.io.IOException;
import java.net.URL;
-
import java.util.ArrayList;
import org.jruby.Ruby;
import org.jruby.RubyInstanceConfig;
import org.jruby.javasupport.JavaEmbedUtils;
-public class Main
-{
- public static void main(String[] args) throws Exception
- {
+public class Main {
+
+ public static void main(String[] args) throws Exception {
RubyInstanceConfig config = new RubyInstanceConfig();
config.setArgv(args);
Ruby runtime = JavaEmbedUtils.initialize(new ArrayList(0), config);
- String mainRubyFile = "main";
-
+ String mainRubyFile = "main";
+ String runConfigFile = "run_configuration";
+
ArrayList<String> config_data = new ArrayList<String>();
try{
- java.io.InputStream ins = Main.class.getClassLoader().getResourceAsStream("run_configuration");
+ java.io.InputStream ins = Main.class.getClassLoader().getResourceAsStream(runConfigFile);
if (ins == null ) {
- System.err.println("Did not find configuration file 'run_configuration', using defaults.");
+ System.err.println("Did not find configuration file '" + runConfigFile + "', using defaults.");
} else {
config_data = getConfigFileContents(ins);
}
}
- catch(IOException ioe)
- {
- System.err.println("Error loading run configuration file 'run_configuration', using defaults: " + ioe);
+ catch(IOException ioe) {
+ System.err.println("IOException loading run configuration file '" + runConfigFile + "', using defaults: " + ioe);
}
- catch(java.lang.NullPointerException npe)
- {
- System.err.println("Error loading run configuration file 'run_configuration', using defaults: " + npe );
+ catch(java.lang.NullPointerException npe) {
+ System.err.println("NullPointerException loading run configuration file '" + runConfigFile + "', using defaults: " + npe );
}
for(String line : config_data) {
- String[] parts = line.split(":");
- if("main_ruby_file".equals(parts[0].replaceAll(" ", ""))) {
- mainRubyFile = parts[1].replaceAll(" ", "");
+ String[] parts = line.split(":");
+ if("main_ruby_file".equals(parts[0].replaceAll(" ", ""))) {
+ mainRubyFile = parts[1].replaceAll(" ", "");
+ }
+
+ if("source_dirs".equals(parts[0].replaceAll(" ", ""))) {
+ String[] source_dirs = parts[1].split(";");
+ for(String s : parts[1].split(";") ){
+ String d = s.replaceAll(" ", "");
+ runtime.evalScriptlet( "$: << '"+d+"/'" );
}
+ }
}
-
runtime.evalScriptlet("require '" + mainRubyFile + "'");
}
@@ -65,3 +69,4 @@ public static URL getResource(String path) {
return(contents);
}
}
+
@@ -8,8 +8,6 @@
$CLASSPATH << 'build/classes'
warn "$LOAD_PATH = \n#{$LOAD_PATH.pretty_inspect}"
-require 'foxtrot.jar'
-
Dir.glob(File.expand_path(File.dirname(__FILE__) + "/**")).each do |directory|
$LOAD_PATH << directory unless directory =~ /\.\w+$/ #File.directory? is broken in current JRuby for dirs inside jars
end
@@ -32,4 +30,4 @@
require 'flickr_browser_controller'
-FlickrBrowserController.instance.open
+FlickrBrowserController.instance.open
@@ -1 +1,14 @@
Place your jars here.
+
+You'll need current versions of:
+
+* miglayout
+* monkeybars
+* jruby-complete
+
+These would ordinarily be installed when you generated a project,
+but since this is a given example the jars are omitted to avoid
+bloating the source distribution.
+
+
+
@@ -1,51 +1,55 @@
-package org.rubyforge.rawr;
+package com.neurogami.rawr;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
import java.io.IOException;
import java.net.URL;
-
import java.util.ArrayList;
import org.jruby.Ruby;
import org.jruby.RubyInstanceConfig;
import org.jruby.javasupport.JavaEmbedUtils;
-public class Main
-{
- public static void main(String[] args) throws Exception
- {
+public class Main {
+
+ public static void main(String[] args) throws Exception {
RubyInstanceConfig config = new RubyInstanceConfig();
config.setArgv(args);
Ruby runtime = JavaEmbedUtils.initialize(new ArrayList(0), config);
- String mainRubyFile = "main";
-
+ String mainRubyFile = "main";
+ String runConfigFile = "run_configuration";
+
ArrayList<String> config_data = new ArrayList<String>();
try{
- java.io.InputStream ins = Main.class.getClassLoader().getResourceAsStream("run_configuration");
+ java.io.InputStream ins = Main.class.getClassLoader().getResourceAsStream(runConfigFile);
if (ins == null ) {
- System.err.println("Did not find configuration file 'run_configuration', using defaults.");
+ System.err.println("Did not find configuration file '" + runConfigFile + "', using defaults.");
} else {
config_data = getConfigFileContents(ins);
}
}
- catch(IOException ioe)
- {
- System.err.println("Error loading run configuration file 'run_configuration', using defaults: " + ioe);
+ catch(IOException ioe) {
+ System.err.println("IOException loading run configuration file '" + runConfigFile + "', using defaults: " + ioe);
}
- catch(java.lang.NullPointerException npe)
- {
- System.err.println("Error loading run configuration file 'run_configuration', using defaults: " + npe );
+ catch(java.lang.NullPointerException npe) {
+ System.err.println("NullPointerException loading run configuration file '" + runConfigFile + "', using defaults: " + npe );
}
for(String line : config_data) {
- String[] parts = line.split(":");
- if("main_ruby_file".equals(parts[0].replaceAll(" ", ""))) {
- mainRubyFile = parts[1].replaceAll(" ", "");
+ String[] parts = line.split(":");
+ if("main_ruby_file".equals(parts[0].replaceAll(" ", ""))) {
+ mainRubyFile = parts[1].replaceAll(" ", "");
+ }
+
+ if("source_dirs".equals(parts[0].replaceAll(" ", ""))) {
+ String[] source_dirs = parts[1].split(";");
+ for(String s : parts[1].split(";") ){
+ String d = s.replaceAll(" ", "");
+ runtime.evalScriptlet( "$: << '"+d+"/'" );
}
+ }
}
-
runtime.evalScriptlet("require '" + mainRubyFile + "'");
}
@@ -65,3 +69,4 @@ public static URL getResource(String path) {
return(contents);
}
}
+
@@ -1 +1,13 @@
Place your jars here.
+
+You'll need current versions of:
+
+* swing-layout
+* monkeybars
+* jruby-complete
+
+Some of these would ordinarily be installed when you generated a project,
+but since this is a given example the jars are omitted to avoid
+bloating the source distribution.
+
+
No changes.
@@ -1,51 +1,55 @@
-package org.rubyforge.rawr;
+package com.neurogami.rawr;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
import java.io.IOException;
import java.net.URL;
-
import java.util.ArrayList;
import org.jruby.Ruby;
import org.jruby.RubyInstanceConfig;
import org.jruby.javasupport.JavaEmbedUtils;
-public class Main
-{
- public static void main(String[] args) throws Exception
- {
+public class Main {
+
+ public static void main(String[] args) throws Exception {
RubyInstanceConfig config = new RubyInstanceConfig();
config.setArgv(args);
Ruby runtime = JavaEmbedUtils.initialize(new ArrayList(0), config);
- String mainRubyFile = "main";
-
+ String mainRubyFile = "main";
+ String runConfigFile = "run_configuration";
+
ArrayList<String> config_data = new ArrayList<String>();
try{
- java.io.InputStream ins = Main.class.getClassLoader().getResourceAsStream("run_configuration");
+ java.io.InputStream ins = Main.class.getClassLoader().getResourceAsStream(runConfigFile);
if (ins == null ) {
- System.err.println("Did not find configuration file 'run_configuration', using defaults.");
+ System.err.println("Did not find configuration file '" + runConfigFile + "', using defaults.");
} else {
config_data = getConfigFileContents(ins);
}
}
- catch(IOException ioe)
- {
- System.err.println("Error loading run configuration file 'run_configuration', using defaults: " + ioe);
+ catch(IOException ioe) {
+ System.err.println("IOException loading run configuration file '" + runConfigFile + "', using defaults: " + ioe);
}
- catch(java.lang.NullPointerException npe)
- {
- System.err.println("Error loading run configuration file 'run_configuration', using defaults: " + npe );
+ catch(java.lang.NullPointerException npe) {
+ System.err.println("NullPointerException loading run configuration file '" + runConfigFile + "', using defaults: " + npe );
}
for(String line : config_data) {
- String[] parts = line.split(":");
- if("main_ruby_file".equals(parts[0].replaceAll(" ", ""))) {
- mainRubyFile = parts[1].replaceAll(" ", "");
+ String[] parts = line.split(":");
+ if("main_ruby_file".equals(parts[0].replaceAll(" ", ""))) {
+ mainRubyFile = parts[1].replaceAll(" ", "");
+ }
+
+ if("source_dirs".equals(parts[0].replaceAll(" ", ""))) {
+ String[] source_dirs = parts[1].split(";");
+ for(String s : parts[1].split(";") ){
+ String d = s.replaceAll(" ", "");
+ runtime.evalScriptlet( "$: << '"+d+"/'" );
}
+ }
}
-
runtime.evalScriptlet("require '" + mainRubyFile + "'");
}
@@ -65,3 +69,4 @@ public static URL getResource(String path) {
return(contents);
}
}
+

0 comments on commit d4f2fe6

Please sign in to comment.