LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   readlink -f which runs in ubuntu doesnt really work right in Red hat any alternative? (http://www.linuxquestions.org/questions/programming-9/readlink-f-which-runs-in-ubuntu-doesnt-really-work-right-in-red-hat-any-alternative-4175469669/)

rohaanembedded 07-15-2013 05:18 AM

readlink -f which runs in ubuntu doesnt really work right in Red hat any alternative?
 
Dear sir,

i am using the
Code:

readlink -f $(which java)
to get the current active java on machine.

it gives output like

Code:

/usr/lib/jvm/java-6-openjdk/jre/bin/java
but when i try to use it in Red Hat (Red Hat Enterprise Linux Server release 5.4 )
its giving me output
Code:

/usr/bin/gij
location of binary

its not giving me location from jvm
how can i get it please let me know

Thanks,

Reagrds
rohan

grail 07-15-2013 05:31 AM

What makes you think the output is incorrect?

If you refer to the man page for readlink:
Code:

-f, --canonicalize
              canonicalize by following every symlink in every component of the given name recursively; all but the last component must exist

The part in red would seem to mean to me that your copy of java is symlinked to the output you have been given.

As is the same with your original output, just it is linked to the jvm version.

rohaanembedded 07-15-2013 05:43 AM

Quote:

Originally Posted by grail (Post 4990502)
What makes you think the output is incorrect?

If you refer to the man page for readlink:
Code:

-f, --canonicalize
              canonicalize by following every symlink in every component of the given name recursively; all but the last component must exist

The part in red would seem to mean to me that your copy of java is symlinked to the output you have been given.

As is the same with your original output, just it is linked to the jvm version.

Dear sir,
Thanks for rply i am getting your point but every where else in the Ubuntu machines i am getting the all path of active java like i told u earlier
Code:

/usr/lib/jvm/java-6-openjdk/jre/bin/java
so now can i get this active configuration of Java on Read Hat?

actually i want to get the active jdk directory
what i am doing in ubuntu is

Code:

OUTPUT=$(readlink -f $(which java))


cd `dirname $OUTPUT`


cd ../../

please do help me

Thanks!!!

regards
rohan

grail 07-15-2013 08:52 AM

It is floored logic to say, something works in Ubuntu so why doesn't it work in Redhat. Whilst some thing may be the same, there is no set in stone fact that one distribution will handle
something exactly the same as another.

What I can tell you is that if both machines had the exact same applications installed and no others, it may well be that you would get the same information returned.
The fact of the matter is that the Redhat install you are looking at is not using jvm as its' copy of java but rather gij (whatever that happens to be)

So I guess the first question I would be asking is, is there a relevant copy of java provided as a jvm installed (as part of jdk, jre, jse)?

Also, does the path you are looking for exist? (the jvm one on the Redhat machine)

Lastly, what does:
Code:

which java
return on the Redhat machine? (you may find it returns more than one)

rohaanembedded 07-15-2013 09:27 AM

Quote:

Originally Posted by grail (Post 4990591)
It is floored logic to say, something works in Ubuntu so why doesn't it work in Redhat. Whilst some thing may be the same, there is no set in stone fact that one distribution will handle
something exactly the same as another.

What I can tell you is that if both machines had the exact same applications installed and no others, it may well be that you would get the same information returned.
The fact of the matter is that the Redhat install you are looking at is not using jvm as its' copy of java but rather gij (whatever that happens to be)

So I guess the first question I would be asking is, is there a relevant copy of java provided as a jvm installed (as part of jdk, jre, jse)?

Also, does the path you are looking for exist? (the jvm one on the Redhat machine)

Lastly, what does:
Code:

which java
return on the Redhat machine? (you may find it returns more than one)

Dear sir,

The path i am looking for is there because when i do

Code:

update-alternatives --config java
it gives me the path for alteration
like
Code:

/usr/lib/jvm/jre-1.4.2-gcj/bin/java
so its there

thanks for reply sir
regards
rohan

grail 07-15-2013 11:37 AM

Well I am not overly familiar with update-alternatives as I do not use Ubuntu or Redhat, but just so I am following:

1. You have used the command update-alternatives and successfully changed /usr/bin/java to point to /usr/lib/jvm/jre-1.4.2-gcj/bin/java?

2. You have confirmed the following:
Code:

$ which java
/usr/bin/java
$ ls -l /usr/bin/java
lrwxrwxrwx 1 root root 40 08.07.2013 19:40 /usr/bin/java -> /usr/lib/jvm/jre-1.4.2-gcj/bin/java
$ ls -l /usr/lib/jvm/jre-1.4.2-gcj/bin/java
-rwxr-xr-x 1 root root 5288 08.07.2013 19:40 /usr/lib/jvm/jre-1.4.2-gcj/bin/java

Assuming above all correct ... unfortunately not sure so maybe one of the Redhat guys will see your query and jump on

rohaanembedded 07-15-2013 01:54 PM

Quote:

Originally Posted by grail (Post 4990678)
Well I am not overly familiar with update-alternatives as I do not use Ubuntu or Redhat, but just so I am following:

1. You have used the command update-alternatives and successfully changed /usr/bin/java to point to /usr/lib/jvm/jre-1.4.2-gcj/bin/java?

2. You have confirmed the following:
Code:

$ which java
/usr/bin/java
$ ls -l /usr/bin/java
lrwxrwxrwx 1 root root 40 08.07.2013 19:40 /usr/bin/java -> /usr/lib/jvm/jre-1.4.2-gcj/bin/java
$ ls -l /usr/lib/jvm/jre-1.4.2-gcj/bin/java
-rwxr-xr-x 1 root root 5288 08.07.2013 19:40 /usr/lib/jvm/jre-1.4.2-gcj/bin/java

Assuming above all correct ... unfortunately not sure so maybe one of the Redhat guys will see your query and jump on

Dear sir,
there was the only java available on this that machine and its currently active JAVA jdk

thanks & Regards
rohan

NevemTeve 07-15-2013 02:15 PM

Good Sir,
If you want to know where Java is, use environment variable JAVA_HOME (If it is set. If unset, do nothing.)

rohaanembedded 07-16-2013 12:55 AM

Quote:

Originally Posted by NevemTeve (Post 4990731)
Good Sir,
If you want to know where Java is, use environment variable JAVA_HOME (If it is set. If unset, do nothing.)

dear sir,
Its not set. . .

how come
Code:

readlink -f $(which java)
is not giving me full path on red Hat linux (in every ubuntu i have tried it worked fine)
any idea please let me know

and thanks for your time.

Regards
rohan

unSpawn 07-16-2013 01:53 AM

Use 'readlink -f /etc/alternatives/java'?

NevemTeve 07-16-2013 02:20 AM

> > If you want to know where Java is, use environment variable JAVA_HOME (If it is set. If unset, do nothing.)

> Its not set. . .

Then do nothing:
Code:

if [ -z "$JAVA_HOME" ]; then
    echo "This script needs JAVA_HOME to be set"
    exit 1;
fi


evo2 07-16-2013 02:34 AM

Hi,

ohh, this game again. We played it once before for Debian (and derived) systems.
https://www.linuxquestions.org/quest...re-4175468115/

So now you want to dump some .jar files on RHEL systems too. Have you considered using rpms? Also have you considered that you don't actually need to dump your files where the system files reside?I'm not a java guy, but a quick search found the following. http://docs.oracle.com/javase/tutori...ent/paths.html

Evo2.

ta0kira 07-16-2013 08:08 AM

  1. If you web-search for "gij", you'll see that it's the GNU version of java.
  2. Why do you need to know the location of the file that contains the actual binary code? Why not just take the value of which java and leave it at that? Symlinks like that are meant to hide things for a reason. That reason is generally for compatibility, but compatibility only works if you let the distro lie to you sometimes.
  3. Did you try running gij to see if it does what you expect java to do?
Kevin Barry

rohaanembedded 07-16-2013 09:17 AM

Quote:

Originally Posted by ta0kira (Post 4991219)
  1. If you web-search for "gij", you'll see that it's the GNU version of java.
  2. Why do you need to know the location of the file that contains the actual binary code? Why not just take the value of which java and leave it at that? Symlinks like that are meant to hide things for a reason. That reason is generally for compatibility, but compatibility only works if you let the distro lie to you sometimes.
  3. Did you try running gij to see if it does what you expect java to do?
Kevin Barry

Dear sir,

Thanks for valueable rply

i agree about the fact of the symlinks are useful in compatibility, but is there any way to get the full path of actual directory

i want to know the location because i want to install one java library bin file at active configuration directory through my script
so have to know the location in ubuntu i am getting the location through
Code:

readlink -f $(which java)
if want any more information please let me know and help me

Regards
rohan

rohaanembedded 07-16-2013 09:36 AM

Quote:

Originally Posted by evo2 (Post 4991086)
Hi,

ohh, this game again. We played it once before for Debian (and derived) systems.
https://www.linuxquestions.org/quest...re-4175468115/

So now you want to dump some .jar files on RHEL systems too. Have you considered using rpms? Also have you considered that you don't actually need to dump your files where the system files reside?I'm not a java guy, but a quick search found the following. http://docs.oracle.com/javase/tutori...ent/paths.html

Evo2.

Dear sir,
yes sir i am trying the same thing as i dont want to use the internet so not going for rpms
i am trying to install the bin through script only
is there any way to get the path (directory) of active java configuration.
please let me know if there is any idea. or command that can be used

Thanks & Regards
Rohan


All times are GMT -5. The time now is 08:20 PM.