Hello.
I’m working with jruby (without rails).
I need to get a ressource file in my jar.
In java, I can do this with getClass().getRessource(‘monFichier.txt’)
How can i do this with jRuby?
Hello.
I’m working with jruby (without rails).
I need to get a ressource file in my jar.
In java, I can do this with getClass().getRessource(‘monFichier.txt’)
How can i do this with jRuby?
On Tue, Aug 24, 2010 at 1:21 PM, Jluc A. [email protected]
wrote:
Hello.
I’m working with jruby (without rails).
I need to get a ressource file in my jar.In java, I can do this with getClass().getRessource(‘monFichier.txt’)
How can i do this with jRuby?
Probably the simplest way would be to do:
require 'jruby'
JRuby.runtime.jruby_class_loader.get_resource("monFichier.txt)
/Nick
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email
Nick S. wrote:
Probably the simplest way would be to do:
require 'jruby' JRuby.runtime.jruby_class_loader.get_resource("monFichier.txt)
thanks it’s work, but only when i am in a jarfile
with javawebstart it doesn’t work
my code:
fichier_base =
JRuby.runtime.jruby_class_loader.get_resource(‘lib/lanceur.db.h2.db’)
File.syscopy fichier_base, File.join($HOME, ‘base’)
the error stack:
classpath:/META-INF/jruby.home/lib/ruby/1.8/ftools.rb:59:in syscopy': No such file or directory - /home/kantena/http:/192.168.2.9/monbuild/coucou.jar!/lib/lanceur.db.h2.db (Errno::ENOENT) from classpath:/chemins.rb:12 from classpath:/chemins.rb:2:in
require’
from Main.rb:2
…internal jruby stack elided…
from #Class:01x12b72f4.syscopy(classpath:/chemins.rb:12)
from (unknown).(unknown)(classpath:/chemins.rb:2)
from Kernel.require(Main.rb:2)
from (unknown).(unknown)(:1)
the path is wrong
On Wed, Aug 25, 2010 at 2:47 AM, Jluc A. [email protected]
wrote:
with javawebstart it doesn’t work
my code:
fichier_base =
JRuby.runtime.jruby_class_loader.get_resource(‘lib/lanceur.db.h2.db’)
File.syscopy fichier_base, File.join($HOME, ‘base’)
Instead try:
fichier_base =
JRuby.runtime.jruby_class_loader.get_resource(‘lib/lanceur.db.h2.db’)
File.open(File.join($HOME, ‘base’, ‘lanceur.db.h2.db’), “w”) do |out|
begin
stream = fichier_base.open_stream
out << stream.to_io.read
ensure
stream.close
end
end
We’re using java.net.URL#openStream here to read the contents rather
than expecting that the file exists locally such that it can be
copied.
/Nick
…internal jruby stack elided…
To unsubscribe from this list, please visit:
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs