I think there's a whole lot of misunderstandings going on here.
1. It really doesn't make sense to set an environment variable like this
after the JVM has started running. LD_LIBRARY_PATH is used by the system loader to decide where to look for loadable native libraries. By the time your Java program is running, this lookup has almost certainly already happened.
2. "setenv" (like "cd") is an example of a command which is not a real executable, instead it is built in to some of the various shells (command interfaces) on Unix. When you run an external command from Java, the commands you give are not passed to command shell, but looked up and executed directly. You can't run "setenv" like that.
3. Even if you do manage to run a "setenv" (by invoking a command shell and passing the "setenv" as command optionm to it, for example), such settings only last for the life of that shell process. Whan called from Java, such processes only last as long as the command takes to execute, then they are ended and all the context information they contain is discarded. So such a "setenv" would have no effect on later code.
4. " `pwd` " is an example of a command shell escape sequence. If you type it in to a running command shell it will execute the command inside the "ticks", and put the resulting output in the command. In the case of the example you give, it would add the value of "pwd" (the name of the current working directory) to the LD_LIBRARY_PATH.
Such escape sequences make no sense when called from a Java program. Note that for this to work, you need to make sure to use "back-ticks" (`), rather than the regular single-quote characters.
5. You never really know what entries there might already be in a path variable like LD_LIBRARY_PATH, so it is almost always wise to
include any old value just in case.
The solution to all of this is to make a small "shell script" file containing something like the following:
For the sake of this discussion we'll call the file 'myjava' - note there is no "file type extension". then type
chmod a+x myjava
which will make it executable. Now
you should be able to just type "myjava" and it will set up your environment and run your java program.