Hello
I am trying to run some JRuby script and I have to set the CLASSPATH
for my script to work.
I use a launcher locally so I can run the script as
./scripts/mylauncher script.rb
but if I wanted to distribute a sample script this is somewhat
troublesome.
I tried to embed the ruby code in a shell script but as Ruby refuses
to read the code from stdin this is not quite nice:
#!/bin/sh
CLASSPATH= jruby -e ’
’ “$@”
Note that while this example uses JRuby there might be native
extensions which require specific environment settings and woud have
the same launcher requirements.
If somebody had a better idea for a launcher it would be nice.
Thanks
Michal
Michal S. wrote:
I am trying to run some JRuby script and I have to set the CLASSPATH
for my script to work.
[…]
Note that while this example uses JRuby there might be native
extensions which require specific environment settings and woud have
the same launcher requirements.
To rephrase: Your software requires some environment variables to be set
in order to run. The standard way of providing this is is to install a
script with the executable bit set in /etc/profile.d/ that modifies the
environment variables on login, e.g.:
/etc/profile.d/mypackage.sh:
export CLASSPATH="$CLASSPATH:/additional/class/paths"
/etc/profile is read on login and should run any executable scripts it
finds in /etc/profile.d/.
Hope this helps,
Henning
On 23 May 2010 13:55, Henning B. [email protected] wrote:
in order to run. The standard way of providing this is is to install a
Hope this helps,
Henning
Well, actually it does not.
If I wanted to distribute the script in multiple files then
distributing it with a launcher would be just fine and would not
require the user of the script to have administrative privileges to
install the script in a system directory nor the additional knowledge
how to make it effective without restarting his session.
However, I was aiming for one self-contained example which is easy to
distribute so I wanted one file.
Also I do not want to inflate the environment needlessly while the
script is not in use. It is not a good practice, the environment space
is limited.
Thanks
Michal
On 25 May 2010 21:56, Charles Oliver N. [email protected] wrote:
distribute so I wanted one file.
Alternatively you can just throw everything in the same jar if there
aren’t file conflicts…
The thing is that I do have to set the CLASSPATH for my application to
work, and even set LD_LIBRARY_PATH in some cases, even if everything
is in one jar.
Also setting $CLASSPATH does not work anyway:
java/lang/ClassLoader.java:1649:in loadLibrary': java.lang.UnsatisfiedLinkError: Can't load library: /InsightToolkit.jar must be in CLASSPATH/libSwigRuntimeJava.so (NativeException) from java/lang/Runtime.java:787:in
load0’
from java/lang/Runtime.java:775:in load' from InsightToolkit/itkbase.java:60:in
’
from InsightToolkit/itkImageFileReader_2DJNI.java:1493:in
<clinit>' from InsightToolkit/itkImageFileReaderF2.java:67:in
itkImageFileReaderF2_New’
from ./testscript.rb:29
Thanks
Michal
On Sun, May 23, 2010 at 5:18 PM, Michal S. [email protected]
wrote:
Well, actually it does not.
If I wanted to distribute the script in multiple files then
distributing it with a launcher would be just fine and would not
require the user of the script to have administrative privileges to
install the script in a system directory nor the additional knowledge
how to make it effective without restarting his session.
However, I was aiming for one self-contained example which is easy to
distribute so I wanted one file.
You can generally get by using the runtime CLASSPATH in JRuby:
require ‘java’
$CLASSPATH << ‘somefile.jar’
This doesn’t always work, since it’s using a child classloader in
JRuby to handle all the classpath entries, but it often works well
enough for a simple self-contained app.
Alternatively you can just throw everything in the same jar if there
aren’t file conflicts…