LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This 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

Reply
 
Search this Thread
Old 03-20-2007, 10:40 AM   #1
bilal_linux
LQ Newbie
 
Registered: Mar 2007
Posts: 15

Rep: Reputation: 0
JDK1.5.0 installation


Hi, i currently have jre1.4.2 installed on linux and using the following procedure to install jdk1.5.0:

- ./jdk-1_5_0_01-linux-i586.bin

it extracts all the files - does not give any error. but after this when i execute java -version command, it still show JRE version 1.4.2.

where am i doing wrong and what should i do to get 1.5.0 up and running?
 
Old 03-20-2007, 10:50 AM   #2
Clemente
Member
 
Registered: Aug 2003
Distribution: Debian, Ubuntu
Posts: 188

Rep: Reputation: 30
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).
 
Old 03-20-2007, 11:02 AM   #3
lumix
Member
 
Registered: Mar 2007
Distribution: Hardy (Gnome on Ubuntu 8.04) on Compaq N600c laptop
Posts: 323

Rep: Reputation: 30
Clemente: yeah, I just figured that out, BUT, I'm looking at my etc/profile and here in black and white is:

if [ "`id -u`" -eq 0 ]; then
PATH="/usr/java/jdk1.5.0_11/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
else
PATH="/usr/java/jdk1.5.0_11/bin:/usr/local/bin:/usr/bin:/bin:/usr/games"

But no such java path from "env". Why?
 
Old 03-20-2007, 11:24 AM   #4
Clemente
Member
 
Registered: Aug 2003
Distribution: Debian, Ubuntu
Posts: 188

Rep: Reputation: 30
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.
 
Old 03-20-2007, 11:27 AM   #5
jay73
Guru
 
Registered: Nov 2006
Location: Belgium
Distribution: Ubuntu 11.04, Debian testing
Posts: 5,019

Rep: Reputation: 130Reputation: 130
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.
 
Old 03-20-2007, 11:45 AM   #6
lumix
Member
 
Registered: Mar 2007
Distribution: Hardy (Gnome on Ubuntu 8.04) on Compaq N600c laptop
Posts: 323

Rep: Reputation: 30
/etc/profile

# /etc/profile: system-wide .profile file for the Bourne shell (sh(1))
# and Bourne compatible shells (bash(1), ksh(1), ash(1), ...).

if [ "`id -u`" -eq 0 ]; then
PATH="/usr/java/jdk1.5.0_11/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
else
PATH="/usr/java/jdk1.5.0_11/bin:/usr/local/bin:/usr/bin:/bin:/usr/games"

fi

if [ "$PS1" ]; then
if [ "$BASH" ]; then
PS1='\u@\h:\w\$ '
else
if [ "`id -u`" -eq 0 ]; then
PS1='# '
else
PS1='$ '
fi
fi
fi

export PATH

umask 022

JAVA_HOME=/usr/java/jdk1.5.0_11/
export JAVA_HOME
 
Old 03-20-2007, 11:49 AM   #7
lumix
Member
 
Registered: Mar 2007
Distribution: Hardy (Gnome on Ubuntu 8.04) on Compaq N600c laptop
Posts: 323

Rep: Reputation: 30
Wow, sorry... I think I just hijacked someone's thread...

Had a similar title and content. But the questions might still apply.
 
Old 03-20-2007, 12:01 PM   #8
Clemente
Member
 
Registered: Aug 2003
Distribution: Debian, Ubuntu
Posts: 188

Rep: Reputation: 30
@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

Last edited by Clemente; 03-20-2007 at 12:05 PM.
 
Old 03-20-2007, 12:30 PM   #9
jay73
Guru
 
Registered: Nov 2006
Location: Belgium
Distribution: Ubuntu 11.04, Debian testing
Posts: 5,019

Rep: Reputation: 130Reputation: 130
Clemente,

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.

Last edited by jay73; 03-20-2007 at 12:36 PM.
 
Old 03-20-2007, 01:20 PM   #10
Clemente
Member
 
Registered: Aug 2003
Distribution: Debian, Ubuntu
Posts: 188

Rep: Reputation: 30
@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.
 
Old 03-20-2007, 01:20 PM   #11
Clemente
Member
 
Registered: Aug 2003
Distribution: Debian, Ubuntu
Posts: 188

Rep: Reputation: 30
--- sorry! deleted due to double posting --
 
Old 03-20-2007, 01:31 PM   #12
jay73
Guru
 
Registered: Nov 2006
Location: Belgium
Distribution: Ubuntu 11.04, Debian testing
Posts: 5,019

Rep: Reputation: 130Reputation: 130
OK, that makes a lot of sense. Thanks for taking the time.
 
Old 03-21-2007, 05:59 AM   #13
bilal_linux
LQ Newbie
 
Registered: Mar 2007
Posts: 15

Original Poster
Rep: Reputation: 0
made a mess of everything

I think i have now screwed up everything. i added the following lines at the end of /etc/profile

PATH=/usr/java/jdk1.5.0_01/bin
export PATH

now when i try and execute ll command or any other command, i get the following message:

- bash: ls: command not found

when i check the java version, i get

Error occured during initialization of VM
could not reserve enough space for object heap
could not create the java virual machine

how can i get the old settings back? any help would be highly appreciated.

Quote:
Originally Posted by bilal_linux
Hi, i currently have jre1.4.2 installed on linux and using the following procedure to install jdk1.5.0:

- ./jdk-1_5_0_01-linux-i586.bin

it extracts all the files - does not give any error. but after this when i execute java -version command, it still show JRE version 1.4.2.

where am i doing wrong and what should i do to get 1.5.0 up and running?
 
Old 03-21-2007, 06:34 AM   #14
bilal_linux
LQ Newbie
 
Registered: Mar 2007
Posts: 15

Original Poster
Rep: Reputation: 0
issue fixed

luckily i have managed to sort it out

Quote:
Originally Posted by bilal_linux
I think i have now screwed up everything. i added the following lines at the end of /etc/profile

PATH=/usr/java/jdk1.5.0_01/bin
export PATH

now when i try and execute ll command or any other command, i get the following message:

- bash: ls: command not found

when i check the java version, i get

Error occured during initialization of VM
could not reserve enough space for object heap
could not create the java virual machine

how can i get the old settings back? any help would be highly appreciated.
 
Old 03-21-2007, 08:04 AM   #15
Clemente
Member
 
Registered: Aug 2003
Distribution: Debian, Ubuntu
Posts: 188

Rep: Reputation: 30
Hi,
change
Code:
PATH=/usr/java/jdk1.5.0_01/bin
export PATH
to
Code:
PATH=/usr/java/jdk1.5.0_01/bin:$PATH
export PATH
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
 
  


Reply

Tags
jdk


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
problem in psotgres7.4 with jdk1.3 mufy General 0 10-19-2004 05:44 AM
java jdk1.4.2 & free: installation performed but javac doesn't run Dominik *BSD 3 02-18-2004 03:42 AM
JDK1.3 and Fonts cptfuture Linux - Software 2 05-26-2001 10:57 AM
JAVA Jdk1.3????? oulevon Programming 0 03-04-2001 06:47 PM
Path for jdk1.3.0_02 oulevon Linux - Newbie 1 03-01-2001 08:06 PM


All times are GMT -5. The time now is 12:05 AM.

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