0

To run java I need library ld-linux.so.3 to sit in the /lib directory. I need this library to sit in a different place. How can I specify to java to look for it in a different directory? for instance /home/dan/libs/

Edit: I tried running java -Djava.library.path=/home/dan/libs

but I still get the error ./java: No such file or directory

jh314
  • 27,144
  • 16
  • 62
  • 82
danidin
  • 371
  • 2
  • 17
  • maybe: http://stackoverflow.com/questions/16227045/how-to-add-so-file-to-the-java-library-path-in-linux –  Apr 28 '15 at 05:36

2 Answers2

1

The 'java' program doesn't search for ld-linux. ld-linux is a loader (hence the name) and runs before the executable, in this case java, even starts. That's why it's your shell reporting that java couldn't be started, not java reporting that it had trouble initializing something. There are ways to change where ld-linux searches for other shared libraries needed by an executable but they can't work for ld-linux itself, because (as far as we can observe) the universe is causal and time flows in one direction.

I haven't tried it, but the accepted answer to https://unix.stackexchange.com/questions/17428/moved-bin-and-other-folders-how-to-get-them-back (where someone accidentally moved their /lib including /lib/ld-linux* to the wrong place) says you can explicitly run a specified ld-linux (presumably any working one) and have it run your executable, here java (presumably with appropriate arguments).

But I wonder why you think you need to change ld-linux, since it's actually gone once the program runs. If you just want to change what gets loaded, LD_LIBRARY_PATH and maybe LD_PRELOAD can do that, without any change to ld-linux.

Community
  • 1
  • 1
dave_thompson_085
  • 34,712
  • 6
  • 50
  • 70
-1

As I understood from your question, you need to change the Java environment variable to point to another directory..

Environment variables are set in the bashrc file, so to edit this file do the following

1- Open the terminal

`CTRL + ALT + DEL`

2- Open the bashrc file for editing

nano ~/.bashrc

3- Edit JAVA_HOME variable if exist of does not exist do the following

export JAVA_HOME= new Java path
export PATH=$PATH:$JAVA_HOME/bin

4- Save the file CTRL +X + Y + Enter 5- Apply the changes

source ~/.bashrc
Ahmed Abobakr
  • 1,618
  • 18
  • 26
  • No, what i need is to tell java to search for the ld-linux.so.3 lib in a specific directory that i define instead of the default /lib directory – danidin Apr 28 '15 at 06:14