From: Michal Suchanek Date: 2010-05-26T06:38:56+09:00 Subject: Re: Ruby one-file launcher that sets up environment? On 25 May 2010 21:56, Charles Oliver Nutter wrote: > On Sun, May 23, 2010 at 5:18 PM, Michal Suchanek 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... > 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 `' from InsightToolkit/itkImageFileReaderF2.java:67:in `itkImageFileReaderF2_New' from ./testscript.rb:29 Thanks Michal