www.centos.org Forum Index CentOS 4 - Software Support Installing Sun Java JDK for Users
|
Bottom Previous Topic Next Topic |
|
| |
|
|
|---|
| Poster | Thread | Rated: 5 Votes |
|---|
|
Re: Installing Sun Java JDK for Users | #2 |
|
|---|---|---|---|
|
Professional Board Member
![]()
Joined: 2005/11/29
From Indiana
Posts: 2283
|
Reconfiguring CentOS 4's default Java configuration
This is done as root or equivalent. First remove /var/lib/alternatives/java file by typing; rm /var/lib/alternatives/java When asked press the 'y' key, Now to create the new (corrected) alternatives file for java type the following commands as root (modify for jdk as needed); /usr/sbin/alternatives --install /usr/bin/java java /usr/lib/jvm/jre-1.4.2-gcj/bin/java 1 /usr/sbin/alternatives --install /usr/bin/java java /usr/java/j2re1.5.0_09/bin/java 2 /usr/sbin/alternatives --config java You should now see for example: There are 2 programs which provide 'java'. Selection Command ----------------------------------------------- 1 /usr/lib/jvm/jre-1.4.2-gcj/bin/java *+ 2 /usr/java/j2re1.5.0_09/bin/java Enter to keep the current selection[+], or type selection number: Type: <choose 1 or 2> In the example above java is already configured correctly [*+ 2] to use Sun's Java, no changes are needed, just press the Enter key here. If you have been following the instructions then you should have the same results (version numbers may be sightly different). Now type; /usr/sbin/alternatives --display java You should see for example; java - status is manual. link currently points to /usr/java/j2re1.5.0_09/bin/java /usr/lib/jvm/jre-1.4.2-gcj/bin/java - priority 1 /usr/java/j2re1.5.0_09/bin/java - priority 2 Current `best' version is /usr/java/j2re1.5.0_09/bin/java. Next you might want to create (or edit) /etc/profile.d/java.sh file, example below; export JAVA_HOME="/usr/java/jre1.5.0_09/bin" export JAVA_PATH="$JAVA_HOME" export PATH="$PATH:$JAVA_HOME" When done creating or editing the file type; source /etc/profile.d/java.sh Now any user root or other wise should be able to use the command; which java and the results should read something like; /usr/java/jre1.5.0_09/bin/java Also any user root or other wize should be able to use the command; java -version and the results should read something like; java version "1.5.0_09" Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_09-b01) Java HotSpot(TM) Client VM (build 1.5.0_09-b01, mixed mode, sharing) That's it, all done. |
||
|
_________________
CentOS: The Sysadmins choice Congratulations NedSlider |
|||
Posted on: 2006/10/20 12:31
|
|||
|
Re: Installing Sun Java JDK for Users | #3 |
|
|---|---|---|---|
|
Newbie
![]()
Joined: 2006/10/20
From
Posts: 2
|
Thank you very much, works like a charm now.
You rock! |
||
Posted on: 2006/10/21 10:02
|
|||
|
Re: Installing Sun Java JDK for Users | #4 |
|
|---|---|---|---|
|
Professional Board Member
![]()
Joined: 2005/11/29
From Indiana
Posts: 2283
|
Your welcome, glad to help.
Enjoy ;) |
||
|
_________________
CentOS: The Sysadmins choice Congratulations NedSlider |
|||
Posted on: 2006/10/22 1:05
|
|||
|
Re: Installing Sun Java JDK for Users | #5 |
|
|---|---|---|---|
|
Newbie
![]()
Joined: 2006/12/21
From
Posts: 1
|
This is a great thread.... I would also like to add...
if this does not work: -sh-3.00$ java -version Error occurred during initialization of VM Could not reserve enough space for object heap Could not create the Java virtual machine. and only this (4mb or less) works for you as a non-root user, under WHM/cPanel -sh-3.00$ java -Xmx4m -version java version "1.5.0_06" Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05) Java HotSpot(TM) Client VM (build 1.5.0_06-b05, mixed mode) It is because you have SHELL FORK BOMB PROTECTION on in WHM. Turn it off - and you will have normal results. Smoge |
||
Posted on: 2006/12/21 17:06
|
|||
|
Re: Installing Sun Java JDK for Users | #6 |
|
|---|---|---|---|
|
Newbie
![]()
Joined: 2007/1/19
From
Posts: 9
|
I did that but at the last step it was still displaying the last jre version (1.4.2_05)...
Now please help me find out the problem. I suspect because I didn't have the "/etc/profile.d/java.sh ". And created it myself and uploaded it to the right directory, and change the permissions to what other files in that directory had..Maybe I ruined something here. OR I didn't install the rpm.bin in the correct directory (but this is irrelevant..) Tried several times. Exhausted. But I do need the last JRE installed AND be the main one. Anyways, here's all the commands I ran and results I got as the root user: root@ser1 [~]# rm /var/lib/alternatives/java rm: remove regular file `/var/lib/alternatives/java'? y root@ser1 [~]# /usr/sbin/alternatives --install /usr/bin/java java /usr/lib/jvm/jre-1.4.2-gcj/bin/java 1 root@ser1 [~]# /usr/sbin/alternatives --install /usr/bin/java java /usr/java/jre1.6.0/bin/java 2 root@ser1 [~]# /usr/sbin/alternatives --config java There are 2 programs which provide 'java'. Selection Command ----------------------------------------------- 1 /usr/lib/jvm/jre-1.4.2-gcj/bin/java *+ 2 /usr/java/jre1.6.0/bin/java Enter to keep the current selection[+], or type selection number: root@ser1 [~]# /usr/sbin/alternatives --display java java - status is manual. link currently points to /usr/java/jre1.6.0/bin/java /usr/lib/jvm/jre-1.4.2-gcj/bin/java - priority 1 /usr/java/jre1.6.0/bin/java - priority 2 Current `best' version is /usr/java/jre1.6.0/bin/java. root@ser1 [~]# source /etc/profile.d/java.sh root@ser1 [~]# which java /usr/local/jdk/bin/java root@ser1 [~]# java -version java version "1.4.2_05" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_05-b04) Java HotSpot(TM) Client VM (build 1.4.2_05-b04, mixed mode) root@ser1 [~]# |
||
Posted on: 2007/1/19 22:38
|
|||
|
Re: Installing Sun Java JDK for Users | #7 |
|
|---|---|---|---|
|
Professional Board Member
![]()
Joined: 2005/11/29
From Indiana
Posts: 2283
|
Try again it does work, just in care you want to check your /etc/profile.d/java.sh file;
$ java -version java version "1.6.0" Java(TM) SE Runtime Environment (build 1.6.0-b105) Java HotSpot(TM) Client VM (build 1.6.0-b105, mixed mode, sharing) $ cat /etc/profile.d/java.sh export JAVA_HOME="/usr/java/jre1.6.0/bin/bin" export JAVA_PATH="$JAVA_HOME" export PATH="$PATH:$JAVA_HOME" $ ls -al /etc/profile.d/java.sh -rwxr-xr-x 1 root root 109 Jan 16 10:20 /etc/profile.d/java.sh FYI: it is best to completely log out the GUI session when done $ rpm -qa --qf="%{n}-%{v}-%{r}.%{arch}\n" jdk jre jre-1.6.0-fcs.i586 jdk-1.6.0-fcs.x86_64 |
||
|
_________________
CentOS: The Sysadmins choice Congratulations NedSlider |
|||
Posted on: 2007/1/20 0:46
|
|||
|
Re: Installing Sun Java JDK for Users | #8 |
|
|---|---|---|---|
|
Newbie
![]()
Joined: 2007/1/19
From
Posts: 9
|
I tried. no success :(
java.sh file is like you wrote and with same permissions (same content, paths) rpm -qa command gives: jre-1.6.0-fcs.i586 but java -version still gives: java version "1.4.2_05" I am almost sure that I didnt show the correct path in this line: root@ser1 [~]# /usr/sbin/alternatives --install /usr/bin/java java /usr/lib/jvm/jre-1.4.2-gcj/bin/java 1 The reason: I see no "jre-1.4.2-gcj" folder under "/usr/lib/jvm". In fact I have nothing within that folder (nofolder and no files at all - empty) So I tried and changed that path with the one showing currently when "which java" command ran: /usr/local/jdk/bin/java But same result - java version "1.4.2_05" What path should I fill in there? Bare with me, a beginner afteral. Thanks for your help. |
||
Posted on: 2007/1/20 18:41
|
|||
|
Re: Installing Sun Java JDK for Users | #9 |
|
|---|---|---|---|
|
Professional Board Member
![]()
Joined: 2005/11/29
From Indiana
Posts: 2283
|
Let's get some info;
Which 'java' rpms do you have installed; rpm -qa --qf="%{n}-%{v}-%{r}.%{arch}\n" '*gcj*' | sort Tell me about this /usr/local/jdk/bin/java directory, where did it come from and so on. |
||
|
_________________
CentOS: The Sysadmins choice Congratulations NedSlider |
|||
Posted on: 2007/1/20 19:38
|
|||
|
Re: Installing Sun Java JDK for Users | #10 |
|
|---|---|---|---|
|
Newbie
![]()
Joined: 2007/1/19
From
Posts: 9
|
here's my server' java.conf file. please tell me what is the path I need to fill into that line/command.
Maybe I need to do somethin in order for this path to actually have something in the /usr/lib/jvm/ folder . Which in your example is jre-1.4.2-gcj/bin/java 1 Here's the java.conf: # System-wide Java configuration file -*- sh -*- # # JPackage Project <http://www.jpackage.org/> # Location of jar files on the system JAVA_LIBDIR=/usr/share/java # Location of arch-specific jar files on the system JNI_LIBDIR=/usr/lib/java # Root of all JVM installations JVM_ROOT=/usr/lib/jvm # Default jvm JAVA_HOME=$JVM_ROOT/java # Options to pass to the java interpreter JAVACMD_OPTS= |
||
Posted on: 2007/1/20 19:53
|
|||
|
Re: Installing Sun Java JDK for Users | #11 |
|
|---|---|---|---|
|
Newbie
![]()
Joined: 2007/1/19
From
Posts: 9
|
I didn't notice your fast reply (for some reason I dont get messages about new posts).
here's the answers to your questions: - I installed this jre-6-linux-i586-rpm.bin downloaded it from java.sun.com (under j2se section / download) - here's what that command line gives: root@ser1 [~]# rpm -qa --qf="%{n}-%{v}-%{r}.%{arch}\n" '*gcj*' | sort libgcj-3.4.6-3.i386 libgcj4-4.1.0-18.EL4.i386 libgcj4-devel-4.1.0-18.EL4.i386 libgcj-devel-3.4.6-3.i386 root@ser1 [~]# - the /usr/local/jdk/bin/java directory came out when I did all the steps described by you and ran "which java" command Anyways I suspect that the path of the currently installed/displayed java version was incorrectly filled in this command line: /usr/sbin/alternatives --install /usr/bin/java java /usr/lib/jvm/jre-1.4.2-gcj/bin/java 1 As for "and so on" I would only point out that in my first message above I copy&pasted everything I wrote and got in the SSH |
||
Posted on: 2007/1/20 20:53
|
|||
|
Re: Installing Sun Java JDK for Users | #12 |
|
|---|---|---|---|
|
Professional Board Member
![]()
Joined: 2005/11/29
From Indiana
Posts: 2283
|
OK,
First; It is a good idea to (in the future) to report the pathing information to where something is found. My java.conf file is found in the /etc/java/ directory location and reads the same as yours. Sometimes this location is different depending on which version of jre is installed (there are three different jre versions BTW, Sun's, IBM's and Blackdown's). Second: it looks like you have the the default jave lib packages installed, which is just fine. But since you do not seem to have the java-1.4.2-gcj-compat-1.4.2.0-27jpp.noarch.rpm installed skip the step; /usr/sbin/alternatives --install /usr/bin/java java /usr/lib/jvm/jre-1.4.2-gcj/bin/java 1 And just use this step instead; /usr/sbin/alternatives --install /usr/bin/java java /usr/java/jre1.6.0/bin/java 1 Then continue on from the step; /usr/sbin/alternatives --config java ; you should see only the /usr/java/jre1.6.0/bin/java listed. I did configure java (again) on my laptop system to provide the example below, it makes no changes on the laptop since it was already setup. I did add some line spacing to make reading easier; [root@Aspire5000 ~]# rm /var/lib/alternatives/java rm: remove regular file `/var/lib/alternatives/java'? y [root@Aspire5000 ~]# /usr/sbin/alternatives --install /usr/bin/java java /usr/java/jre1.6.0/bin/java 1 [root@Aspire5000 ~]# /usr/sbin/alternatives --config java There is 1 program that provides 'java'. Selection Command ----------------------------------------------- *+ 1 /usr/java/jre1.6.0/bin/java Enter to keep the current selection[+], or type selection number: [root@Aspire5000 ~]# /usr/sbin/alternatives --display java java - status is manual. link currently points to /usr/java/jre1.6.0/bin/java /usr/java/jre1.6.0/bin/java - priority 1 Current `best' version is /usr/java/jre1.6.0/bin/java. [root@Aspire5000 ~]# which java /usr/bin/java [root@Aspire5000 ~]# java -version java version "1.6.0" Java(TM) SE Runtime Environment (build 1.6.0-b105) Java HotSpot(TM) Client VM (build 1.6.0-b105, mixed mode, sharing) You can skip creating the /etc/profile.d/java.sh file and source step like I did, no reason to anyhow you have done them already. |
||
|
_________________
CentOS: The Sysadmins choice Congratulations NedSlider |
|||
Posted on: 2007/1/21 15:32
|
|||
|
Re: Installing Sun Java JDK for Users | #13 |
|
|---|---|---|---|
|
Newbie
![]()
Joined: 2007/1/19
From
Posts: 9
|
Hi, just noticed your reply. Yes I do have the deafult java installed (but obviously want the newest one 1.6.0 to be working with my Java appication).
As suggested by you, I skipped that step. Here's what I did and what I got (I will line space also): root@ser1 [~]# rm /var/lib/alternatives/java rm: remove regular file `/var/lib/alternatives/java'? y root@ser1 [~]# /usr/sbin/alternatives --install /usr/bin/java java /usr/java/jre1.6.0/bin/java 1 root@ser1 [~]# /usr/sbin/alternatives --config java There are 1 programs which provide 'java'. Selection Command ----------------------------------------------- *+ 1 /usr/java/jre1.6.0/bin/java Enter to keep the current selection[+], or type selection number: root@ser1 [~]# /usr/sbin/alternatives --display java java - status is manual. link currently points to /usr/java/jre1.6.0/bin/java /usr/java/jre1.6.0/bin/java - priority 1 Current `best' version is /usr/java/jre1.6.0/bin/java. root@ser1 [~]# which java /usr/local/jdk/bin/java root@ser1 [~]# java -version java version "1.4.2_05" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_05-b04) Java HotSpot(TM) Client VM (build 1.4.2_05-b04, mixed mode) root@ser1 [~]# Note how the last two command replies are different from what you get. I wish I hadn't any Java installed by default on that server. Did I mention its a remote one, maybe this has something to do with it not working as for others.. Thanks for your patience and for the will to make this happen. if you will, let's nail it to the end. |
||
Posted on: 2007/1/23 11:06
|
|||
|
Re: Installing Sun Java JDK for Users | #14 |
|
|---|---|---|---|
|
Professional Board Member
![]()
Joined: 2005/11/29
From Indiana
Posts: 2283
|
OK, once again how did this get to be (the directory);
root@ser1 [~]# which java /usr/local/jdk/bin/java Did you or somebody else install this version of the jdk from a non-rpm package??? If you do not know then ask around a bit. The path if installed from the rpm package (after expanding and installing) is /usr/java does this directory exist and does it have the files /usr/java/jdk1.6.0/bin/java and usr/java/jre1.6.0/bin/java, if yes what happens when you do; /usr/java/jdk1.6.0/bin/java -version /usr/java/jre1.6.0/bin/java -version They should report something like(remember I have the 64-bit version of the jdk rpm package installed); ]$ /usr/java/jdk1.6.0/bin/java -version java version "1.6.0" Java(TM) SE Runtime Environment (build 1.6.0-b105) Java HotSpot(TM) 64-Bit Server VM (build 1.6.0-b105, mixed mode) [lenard@Aspire5000 ~]$ /usr/java/jre1.6.0/bin/java -version java version "1.6.0" Java(TM) SE Runtime Environment (build 1.6.0-b105) Java HotSpot(TM) Client VM (build 1.6.0-b105, mixed mode, sharing) If your results are similar then you have the rpm package installed correctly. As a suggestion you can try removing the entire usr/local/jdk/ directory tree then (once more) run through the configuration steps from my post #12 in this thread. Maybe this remote server is managed by someone else???? Are you renting/leasing this remote server??? Maybe speaking with the host manager may be helpful and provide some insight and/or assistance, if this is a virtual system then this might be the issue. |
||
|
_________________
CentOS: The Sysadmins choice Congratulations NedSlider |
|||
Posted on: 2007/1/23 14:46
|
|||
|
Re: Installing Sun Java JDK for Users | #15 |
|
|---|---|---|---|
|
Newbie
![]()
Joined: 2007/1/19
From
Posts: 9
|
Hello and thanks for your patience (sorry but I didn't find a a PM button on this forum in order to keep this private).
There is a positive progress. here's the answers to your questions and what I did "Did you or somebody else install this version of the jdk from a non-rpm package??? If you do not know then ask around a bit." The server is rented. its a dedicated one. non-managed, meaning managed by myself. And I didn't install this 1.4.2_05 JDK/JRE. It's either been installed by default when server prepared for me OR it got installed when I recompiled Apache with Java enabled (maybe it was executed/installed back then by itself). As for the JRE 1.6.0, afirmative, it was installed by myself from an RPM package downloaded from java.sun.com "The path if installed from the rpm package (after expanding and installing) is /usr/java does this directory exist and does it have the files /usr/java/jdk1.6.0/bin/java and usr/java/jre1.6.0/bin/java, " There is no 'jdk' in the '/usr/java/' folder. And there is indeed /usr/java/jre1.6.0/bin/java proving that the JRE1.6.0. package installed correctly "if yes what happens when you do; /usr/java/jdk1.6.0/bin/java -version /usr/java/jre1.6.0/bin/java -version" Yes it gives this: root@ser1 [~]# /usr/java/jre1.6.0/bin/java -version java version "1.6.0" Java(TM) SE Runtime Environment (build 1.6.0-b105) Java HotSpot(TM) Server VM (build 1.6.0-b105, mixed mode) <<---- here your reult gave also "sharing" "As a suggestion you can try removing the entire usr/local/jdk/ directory tree then (once more) run through the configuration steps from my post #12 in this thread." In the /usr/local/ directory there is : 1. a "j2sdk1.4.2_05" 2. and a 'jdk' shortcut folder that is leading to the above mentioned jdk 1.4.2_05 version I deleted those two folder above. Then ran through the steps from your post #12. It was fine till this command: /usr/sbin/alternatives --config java It gave: -bash: usr/sbin/alternatives: No such file or directory To the following command it gives correct path: root@ser1 [~]# which java /usr/bin/java And to "java -version" command it gives the correct reply: root@ser1 [~]# java -version java version "1.6.0" Java(TM) SE Runtime Environment (build 1.6.0-b105) Java HotSpot(TM) Server VM (build 1.6.0-b105, mixed mode) Looks like the deletion of the early mentioned folder got it solved. But is it 100% solved.. now that it doesn't find "usr/sbin/alternatives" Thanks again |
||
Posted on: 2007/1/23 16:39
|
|||
|
Re: Installing Sun Java JDK for Users | #16 |
|
|---|---|---|---|
|
Newbie
![]()
Joined: 2007/1/19
From
Posts: 9
|
Finally everything shows correctly. It appears to be the uninstalling / deletion of the early install JDK (earlier version) that did the job.
thanks lenard once again |
||
Posted on: 2007/1/23 16:43
|
|||
|
Re: Installing Sun Java JDK for Users | #17 |
|
|---|---|---|---|
|
Professional Board Member
![]()
Joined: 2005/11/29
From Indiana
Posts: 2283
|
Your welcome, glad you got it worked out.
|
||
|
_________________
CentOS: The Sysadmins choice Congratulations NedSlider |
|||
Posted on: 2007/1/23 18:17
|
|||
|
Re: Installing Sun Java JDK for Users | #18 |
|
|---|---|---|---|
|
Newbie
![]()
Joined: 2007/1/19
From
Posts: 9
|
A quick one if you will because am searching quite a bit on the net and decided to address to someone who already helped me out.
I have now installed JMF for this application to run corectly. have followed these steps: http://www.luniks.net/luniksnet/html/java/jtvd/doc/jmf.html But am having problems with step no. 6: "To complete the installation, you should set the environment variables JMFHOME, CLASSPATH and LD_LIBRARY_PATH according to the JMF installation path you have chosen. If you for example have installed JMF to /usr/lib/JMF-2.1.1e, then you could add the following lines to your .profile: export JMFHOME=/usr/lib/JMF-2.1.1e export CLASSPATH=.:$CLASSPATH:$JMFHOME/lib/jmf.jar export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$JMFHOME/lib" To what .profile is this referring to exactly, for I didnt find any in my /usr/lib/JMF-2.1.1e |
||
Posted on: 2007/1/23 23:47
|
|||
|
Re: Installing Sun Java JDK for Users | #19 |
|
|---|---|---|---|
|
Newbie
![]()
Joined: 2007/1/19
From
Posts: 9
|
is it the /etc/.profile and should I add these lines to the end of it
|
||
Posted on: 2007/1/24 0:26
|
|||
|
Re: Installing Sun Java JDK for Users | #20 |
|
|---|---|---|---|
|
Professional Board Member
![]()
Joined: 2005/11/29
From Indiana
Posts: 2283
|
The lines are added to you hidden .bash_profile in your home directory by any text editor.
Example; # .bash_profile # Get the aliases and functions if [ -f ~/.bashrc ]; then . ~/.bashrc fi # User specific environment and startup programs PATH=$PATH:$HOME/bin:. export JMFHOME=/usr/lib/JMF-2.1.1e export CLASSPATH=.:$CLASSPATH:$JMFHOME/lib/jmf.jar export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$JMFHOME/lib" export PATH unset USERNAME |
||
|
_________________
CentOS: The Sysadmins choice Congratulations NedSlider |
|||
Posted on: 2007/1/24 1:27
|
|||
Top Previous Topic Next Topic |
|
|



Topic options
Print Topic
Threaded
Newest First
5 Votes
Mabus




You cannot start a new topic.
You can view topic.