# Executing jar file

**URL:** <https://www.ruby-forum.com/t/executing-jar-file/117904>\
**Category:** Rails\
**Created:** [October 22, 2007, 9:05am UTC](https://www.ruby-forum.com/t/executing-jar-file/117904 "2007-10-22T09:05:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![crazybass](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/eb9ed0/32.png) [@crazybass](https://www.ruby-forum.com/u/crazybass)\
**Post date:** [October 22, 2007, 9:05am UTC](https://www.ruby-forum.com/t/executing-jar-file/117904/1 "2007-10-22T09:05:39Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![crazybass](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/eb9ed0/32.png) [@crazybass](https://www.ruby-forum.com/u/crazybass)\
**Post date:** [October 22, 2007, 2:23pm UTC](https://www.ruby-forum.com/t/executing-jar-file/117904/2 "2007-10-22T14:23:35Z")

</div>

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
