jruby

Can I define a Java subclass in ruby, then instantiate it in Java?

耗尽温柔 提交于 2019-12-22 11:13:25
问题 I'd like to define a superclass in Java, then define a subclass in Ruby, then make instances of that subclass in Java. A little something like this: // Java superclass package myPkg; public class Sup{ public Sup(){} public abstract void foo(String a); } -- # Ruby code include Java require 'jruby/core_ext' include_class 'myPkg.Sup' class RubySub < Java::myPkg.Sup def foo( a ) puts a; end end RubySub.become_java! RubySub -- // Back in Java land Ruby runtime = Ruby.newInstance(); IRubyObect ro =

JRuby - Warbler does not preserve symbolic links

♀尐吖头ヾ 提交于 2019-12-22 10:30:32
问题 When packaging the application using warbler, the symbolic links are lost and the actual contents the symlink points to are packaged as part of the WAR. In my case, I have a symlink from public/images/upload to /var/myproject/upload. After I deploy the war in tomcat, in the exploded folder public/images/upload has all the contents of /var/myproject/upload copied to it instead of linking to the folder. UPDATE: My questions is "will warbler retain the symbolic links inside the project when

Is it possible to create Java classes from JRuby and use them in Java?

前提是你 提交于 2019-12-22 08:20:05
问题 I'm trying to extend Lucene's Analyzer from JRuby and use it from java. A simple analyzer would look like: class MyAnalyzer < Java::OrgApacheLuceneAnalysis::Analyzer def TokenStream (file_name, reader) result = StandardTokenizer.new(Version::LUCENE_CURRENT, reader) result = LowerCaseFilter.new(result) result = LengthFilter.new(result, 3, 50) result = StopFilter.new(result, StandardAnalyzer.STOP_WORDS_SET) result = PorterStemFilter.new(result) result end end Then I compile it: jrubyc -c /home

Is it possible to compile a Rails app to a Java VM JAR file?

◇◆丶佛笑我妖孽 提交于 2019-12-22 03:24:38
问题 Essentially the only thing I can deploy to my deployment machine is a JAR file. I can't install JRuby, nor can I install Glassfish or Tomcat. Is it possible to package up a Rails application (including Rails, vendored, of course) to a JAR file such that I can do c:\my_server> java rails_app.jar and have it run WEBRick or Mongrel within the JVM? 回答1: I'd recommend that you checkout Jetty. The process for Embedding Jetty is surprisingly easy, and it should be possible to give it your servlets

JRuby PermGen out of space even use java objects in ruby code

心已入冬 提交于 2019-12-22 01:18:53
问题 Description: If we use java objects jruby get permgen too: System.out.println("Initialazing.."); //Spring applicaton context WebApplicationContext wac = (WebApplicationContext) AppContext.getApplicationContext(); // prepare path to internal ruby String scriptsPath = wac.getServletContext().getRealPath(RUBY_PATH); String jrubyHome = wac.getServletContext().getRealPath("WEB-INF" + File.separator + "jruby"); // Initializing Scripting container ScriptingContainer container = new

Installing gems from behind a corporate firewall

我们两清 提交于 2019-12-21 12:18:14
问题 I suspect that the corporate firewall is preventing gems from getting installed. I have HTTP_PROXY defined and I'm able to view remote gems via the following command: jruby -S gem list -r But when I go to install a gem, I get a 404: jruby -S gem install rails Is there a good workaround for resolving this issue other than maintaining an internal gem repository? 回答1: for ruby gems, placing this in my gem.bat this works for me @"%~dp0ruby.exe" "%~dpn0" %* --http-proxy http://domainname.ccc.com

How can we have a dynamically typed language over JVM?

帅比萌擦擦* 提交于 2019-12-21 07:56:34
问题 We have Jython , JRuby , Groovy which are dynamically typed and runs over JVM . I understand that these languages compile to bytecode. Other languages such as Scala supports type inference, and its clear that the compiler infers the type for us. But Java is a static language and it compiles to bytecode, does this mean bytecode supports dynamic typing? For e.g. In Java we need to declare the variable type at compile time, and can never change it. But in case of Python we dont have to declare a

How can I create a servlet with jruby (running with jetty)?

烂漫一生 提交于 2019-12-21 06:57:45
问题 I am pretty new to jruby and java and want to create a servlet in jruby while using jetty as web server. I am not sure if I am on the right way with the following code which shows the input form so far. I guess I have to extend now the HttpServlet class to handle the posted data but I don't know how to do this in this case and if it is okay to do this in the same script. require 'java' Dir["./jetty-6.1.18/lib/*jar"].each { |jar| require jar } Dir["./Java/lib/jsdk2.1/javax/*jar"].each { |jar|

How do I specify heap size configuration in a config file

微笑、不失礼 提交于 2019-12-21 06:16:13
问题 gem install fails with the following error, How do I specify the heap size configuration in a common place so that I don't have to re-define this every time. Error: Your application used more memory than the safety cap of 500m. Specify -J-Xmx####m to increase it (#### = cap size in MB). Specify -w for full OutOfMemoryError stack trace. 回答1: This error and message are actually coming from jruby, not gem. Fortunately, jruby checks for default options in the JRUBY_OPTS environment variable. So,

How do I unmarshal a ruby object in java?

耗尽温柔 提交于 2019-12-21 05:16:39
问题 I have a an object that I'd like to grab the contents of in java. The only problem is that is is currently in ruby. irb(main):050:0> blah => "BAh7ByIeYXV0aGVudGljYXRpb25fc3RyYXRlZ2llczAiCXVzZXJpBg%253D%253D-\ -0cdecf4edfaa5cbe4693c9fb83b204c1256a54a6" irb(main):049:0> Marshal.load(Base64.decode64(blah)) => {"authentication_strategies"=>nil, "user"=>1} I got the base64 portion allright -- so now everything is in bytes. How would i access that 2nd string? I presume something can be done with