Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
do you really start the _new_ java executable? You can be sure, if you specify the full path to java. E.g: /usr/local/java/bin/java -version.
If you simply use "java", your bash searches the $PATH for any java executable and launches it. You can check the binary, bash would start with:
If this is your problem, I would advise to add your new java executable path into your $PATH definition (~/.bashrc would be a good place).
Hm. Is there any export PATH, too?
If yes, and if echo $PATH does not show the added java directory, the statements into the /etc/profile are never evaluated or overwriten anywhere. But _where_ is little specific to your system.
Could be some boring work to find it out
In my humble opinion, it would be most safe to add the PATH=blabla; export PATH; into ~/bashrc. Assuming, you use bash as terminal. I think this file is evaluated everytime you start a new bash session and has not so much oportunities to be overwritten.
@jay73: Noack. The -version option is not determined by any magic into /etc/alternatives. /usr/bin/java just symlinks to another symlink into /etc/alternatives. The last symlink points to any java executable, your distributor wants you to use.
If you update your $PATH, you can use _any_ java version in a conveniant way without changing any distributor specific setting. Without using the root password.
And for the same reason, I would not change the /etc/profile, but my own .bashrc file.
@lumix: IIRC, there is are a lot of files evaluated, before you see your terminal. E.g., any export PATH into your ~/.bashrc can effectively override this /etc/profile. I once had a similar problem and spent a lot of time to understand the whole process - and forgot it again
just wondering: it's my understanding that certain applications completely ignore bashrc (e.g. tomcat); how could they be installed without editing /etc/profile? I may be wrong on this subject; it's just what I remember from a lengthy forum debate some time ago and I have since made a habit of adjusting /etc/profile and /etc/alernatives first.
And also, why would /etc/alternatives be irrelevant? Wasn't it introduced presily to allow quick switching from one java kit to another?
Oh yes, and I do have jdk/bin in my bash file, only it's in bash_profile rather than bashrc; I don't think it makes any difference because java runs just as well like that.
@jay73: Sorry for being not precise... The alternative thing is not complete irrelevant and nonsense. Yes, you can use this symink to start any jre. If you do it this way, you propably change a lot of system behaviour. Any program amd any other user suddenly uses another java. It is more minimalistic to do it on a per user level. The way I described.
What I tried to say in my last posting is, that
The result of java -version is determined by the value of java(c) in /etc/alternatives. These need to point to your new jdk or you'll always get the old version instead.
is not correct. The alternatives symlink does not evaluate any -version information. It just determines what java executable is launched. And - more important - if you change the $PATH to /my/java:$PATH - what was discussed before - the alternatives symlink will never be used. So it is irrelevant _in this setting_. That was the reason for my "noack".
Tomcat uses the shell environment to determine what java to use. IIRC it is $JAVA_HOME. So you are right - tomcat ignores the bashrc. But bash doesn't. If you start tomcat from bash, your bashrc dies matter. Not by $PATH but by $JAVA_HOME. If you do launch tomcat in another context, you have to use another mechanism to let tomcat use the desired java version.
The OP initially asked how to get his new java started by typing java -version in a terminal. He did not ask for configuring any java dependant software like tomcat or jboss. I surely would not configure a server system the same way, I'd configure a normal desktop.