LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 07-15-2013, 05:18 AM   #1
rohaanembedded
Member
 
Registered: May 2013
Location: India
Distribution: Ubuntu 11.10
Posts: 174

Rep: Reputation: Disabled
Question 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

Last edited by rohaanembedded; 07-15-2013 at 05:20 AM.
 
Old 07-15-2013, 05:31 AM   #2
grail
Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 7,195

Rep: Reputation: 1796Reputation: 1796Reputation: 1796Reputation: 1796Reputation: 1796Reputation: 1796Reputation: 1796Reputation: 1796Reputation: 1796Reputation: 1796Reputation: 1796
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.
 
1 members found this post helpful.
Old 07-15-2013, 05:43 AM   #3
rohaanembedded
Member
 
Registered: May 2013
Location: India
Distribution: Ubuntu 11.10
Posts: 174

Original Poster
Rep: Reputation: Disabled
Question

Quote:
Originally Posted by grail View Post
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

Last edited by rohaanembedded; 07-15-2013 at 05:50 AM.
 
Old 07-15-2013, 08:52 AM   #4
grail
Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 7,195

Rep: Reputation: 1796Reputation: 1796Reputation: 1796Reputation: 1796Reputation: 1796Reputation: 1796Reputation: 1796Reputation: 1796Reputation: 1796Reputation: 1796Reputation: 1796
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)
 
Old 07-15-2013, 09:27 AM   #5
rohaanembedded
Member
 
Registered: May 2013
Location: India
Distribution: Ubuntu 11.10
Posts: 174

Original Poster
Rep: Reputation: Disabled
Question

Quote:
Originally Posted by grail View Post
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
 
Old 07-15-2013, 11:37 AM   #6
grail
Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 7,195

Rep: Reputation: 1796Reputation: 1796Reputation: 1796Reputation: 1796Reputation: 1796Reputation: 1796Reputation: 1796Reputation: 1796Reputation: 1796Reputation: 1796Reputation: 1796
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
 
Old 07-15-2013, 01:54 PM   #7
rohaanembedded
Member
 
Registered: May 2013
Location: India
Distribution: Ubuntu 11.10
Posts: 174

Original Poster
Rep: Reputation: Disabled
Question

Quote:
Originally Posted by grail View Post
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
 
Old 07-15-2013, 02:15 PM   #8
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 1,456

Rep: Reputation: 445Reputation: 445Reputation: 445Reputation: 445Reputation: 445
Good Sir,
If you want to know where Java is, use environment variable JAVA_HOME (If it is set. If unset, do nothing.)
 
Old 07-16-2013, 12:55 AM   #9
rohaanembedded
Member
 
Registered: May 2013
Location: India
Distribution: Ubuntu 11.10
Posts: 174

Original Poster
Rep: Reputation: Disabled
Question

Quote:
Originally Posted by NevemTeve View Post
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
 
Old 07-16-2013, 01:53 AM   #10
unSpawn
Moderator
 
Registered: May 2001
Posts: 26,534
Blog Entries: 51

Rep: Reputation: 2604Reputation: 2604Reputation: 2604Reputation: 2604Reputation: 2604Reputation: 2604Reputation: 2604Reputation: 2604Reputation: 2604Reputation: 2604Reputation: 2604
Use 'readlink -f /etc/alternatives/java'?
 
Old 07-16-2013, 02:20 AM   #11
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 1,456

Rep: Reputation: 445Reputation: 445Reputation: 445Reputation: 445Reputation: 445
> > 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
 
Old 07-16-2013, 02:34 AM   #12
evo2
Senior Member
 
Registered: Jan 2009
Location: Japan
Distribution: Debian
Posts: 4,822

Rep: Reputation: 1022Reputation: 1022Reputation: 1022Reputation: 1022Reputation: 1022Reputation: 1022Reputation: 1022Reputation: 1022
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.
 
Old 07-16-2013, 08:08 AM   #13
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
  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
 
1 members found this post helpful.
Old 07-16-2013, 09:17 AM   #14
rohaanembedded
Member
 
Registered: May 2013
Location: India
Distribution: Ubuntu 11.10
Posts: 174

Original Poster
Rep: Reputation: Disabled
Unhappy

Quote:
Originally Posted by ta0kira View Post
  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
 
Old 07-16-2013, 09:36 AM   #15
rohaanembedded
Member
 
Registered: May 2013
Location: India
Distribution: Ubuntu 11.10
Posts: 174

Original Poster
Rep: Reputation: Disabled
Unhappy

Quote:
Originally Posted by evo2 View Post
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
./configure command runs... but doesnt work Visual Basic Imp MEPIS 3 01-20-2007 01:33 PM
pc with Win 2k and Red Hat 9.0 runs very slow bakreabhi Linux - Newbie 3 04-08-2004 03:14 AM
Roadster runs Debian but not Red Hat Astro96 Linux - Laptop and Netbook 1 08-19-2003 11:25 PM
squid on red hat 9.0 doesnt work maxut Linux - Networking 3 06-08-2003 04:15 AM


All times are GMT -5. The time now is 09:15 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration