简体   繁体   中英

I want to set an environment variable to my java application while bootstrapping such that the jars in classpath can read it

I have to set LD_LIBRARY_PATH such that one of the jar in my classpath uses that to execute some native java files.

I have tried setting up the environment file to my server while bootstrapping, but System.getenv(LD_LIBRARY_PATH) is given as null.

Library path in use by Java is shown by System.getProperty("java.library.path") . Just print the value in your app when you run it.

java ... your.App

Note the value and edit LD_LIBRARY_PATH before running a second time:

export LD_LIBRARY_PATH=/blahblah
# or export LD_LIBRARY_PATH=/blahblah:$LD_LIBRARY_PATH
java ... your.App

You should see the changed "java.library.path" now prefixed with /blahblah: .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM