Executing jar file

Hello

With my controller i am executing a JAR file like this:

begin
pipe = IO.popen(“java -jar D:/Projets/TstSimple/lib/tstlib.jar”)
rescue Exception => e
msg = e.message
end

I would like to not have to specified the path of the jar file:
pipe = IO.popen(“java -jar tstlib.jar”)

Is there a directory where I can put my JAR file so rails be able to
execute the java command like this?

Thanks

regards

You can reference it with #{RAILS_ROOT}

So something along the lines of

pipe = IO.popen(“java -jar #{RAILS_ROOT}/jars/tstlib.jar”)

and then make a jars folder in the root of your app and place your jar
there.

This should work… might require tweaking, look into using
#{RAILS_ROOT} (as I’m still a bit of a newbie here… and to Rails).

Paulo C. wrote:

Hello

With my controller i am executing a JAR file like this:

begin
pipe = IO.popen(“java -jar D:/Projets/TstSimple/lib/tstlib.jar”)
rescue Exception => e
msg = e.message
end

I would like to not have to specified the path of the jar file:
pipe = IO.popen(“java -jar tstlib.jar”)

Is there a directory where I can put my JAR file so rails be able to
execute the java command like this?

Thanks

regards

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs