Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #31544
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!newsfeed.straub-nv.de!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Eric Sosman <esosman@comcast-dot-net.invalid> |
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: how to set LD_LIBRARY_PATH within the Java program? |
| Date | Thu, 09 Apr 2015 13:20:32 -0400 |
| Organization | A noiseless patient Spider |
| Lines | 31 |
| Message-ID | <mg6cbb$576$1@dont-email.me> (permalink) |
| References | <579a6f03-93e3-4b8c-81d8-c854af1b7654@googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=windows-1252; format=flowed |
| Content-Transfer-Encoding | 7bit |
| Injection-Date | Thu, 9 Apr 2015 17:19:39 +0000 (UTC) |
| Injection-Info | mx02.eternal-september.org; posting-host="858a9d65d95f4ea4d355bd116aa2cdbf"; logging-data="5350"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/D5SLmIMV+g3UTw0+N13YU" |
| User-Agent | Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 |
| In-Reply-To | <579a6f03-93e3-4b8c-81d8-c854af1b7654@googlegroups.com> |
| Cancel-Lock | sha1:S1MA819gX3oRu9Mte+bljqv6B+Y= |
| Xref | csiph.com comp.lang.java.programmer:31544 |
Show key headers only | View raw
On 4/9/2015 11:28 AM, John wrote:
> Hi:
>
> I need to set linux environment variable LD_LIBRARY_PATH within my Java program. The reason is that the Java program calls some linux program which dynamically links to other *.so files. I could do this on the terminal first:
>
> export LD_LIBRARY_PATH=/fs/great/lib:${LD_LIBRARY_PATH}
>
> For some reason, I don't want to do it this way. I want to do it within the Java program. I googled and saw this hacking way,
>
> http://stackoverflow.com/questions/318239/how-do-i-set-environment-variables-from-java
>
> People say it works great. But I don't understand his code, posted below. How to use it in my case. Thank you.
>[...]
People who say "it works great" must be using it for purposes
rather different from yours, or must have a different notion of
what "great" means. The code (if it works at all) will modify
some Java maps in Java's memory, but will not affect the "real"
environment that lives "out there" in Linux or Windows or whatever.
It will change Java's read-only (supposedly) copy of the external
environment, but won't change that external environment -- and since
the library loader will consult the external environment's value of
LD_LIBRARY_PATH, changing Java's internal copy won't help you.
You might, I guess, inspect LD_LIBRARY_PATH yourself, and if it
isn't what you want you could set up a ProcessBuilder with the
desired value and re-launch your program as a sub-process.
--
esosman@comcast-dot-net.invalid
"Don't be afraid of work. Make work afraid of you." -- TLM
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
how to set LD_LIBRARY_PATH within the Java program? John <xsli2@yahoo.com> - 2015-04-09 08:28 -0700
Re: how to set LD_LIBRARY_PATH within the Java program? Eric Sosman <esosman@comcast-dot-net.invalid> - 2015-04-09 13:20 -0400
Re: how to set LD_LIBRARY_PATH within the Java program? "A. Bolmarcich" <aggedor@earl-grey.cloud9.net> - 2015-04-09 16:17 -0500
Re: how to set LD_LIBRARY_PATH within the Java program? Andreas Leitgeb <avl@auth.logic.tuwien.ac.at> - 2015-04-10 11:19 +0000
csiph-web