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.
Notices
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.
Hi,
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:
Code:
which java
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.
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.
@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
Quote:
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.
That should fix your problem.
You did overwrite all other usefull entries in your $PATH - so bash cannot find any program like ls, ...
No big problem
Clemente
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.