Installing Sun Java JDK for Users

Issues related to software problems

Installing Sun Java JDK for Users

Postby Mabus » 2006/10/20 02:11:15

Hello there,

I have a host with a server for a free game I wish to run. It is a MUD codebase called "CoffeeMud" and is Java based. it requires the latest Sun Java JDK.

The host runs CENTOS 4 2.6.9-42.0.2.ELsmp

He has attempted to install Java, but gets several errors when attempting to access it.

[~]# java -version
Error occurred during initialization of VM
Could not reserve enough space for object heap
Could not create the Java virtual machine.

[~]# java -Xmx4m -version
java version "1.5.0_08"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_08-b03)
Java HotSpot(TM) Client VM (build 1.5.0_08-b03, mixed mode)

[~]# java -Xmx32m -version
Error occurred during initialization of VM
Could not reserve enough space for object heap
Could not create the Java virtual machine.

[~]# which java
/usr/java/jdk1.5.0_08/bin/java

[~]# java -Xmx8m -version
Error occurred during initialization of VM
java.lang.OutOfMemoryError: unable to create new native thread

Beyond this only root seems to have access. He even set the user to have all root groups, so (to us at least) it does not seem to be a permissions error.

He also wishes to keep the gcj(?) version of java with the new installation. Is this possible with using alternatives? If so any help with that would be a dang good thing as well.

My thanks to those of you that have read this.

Any thoughts or help dealing with this issue would be highly appreciated.
Mabus
 
Posts: 2
Joined: 2006/10/20 01:06:40

Re: Installing Sun Java JDK for Users

Postby Lenard » 2006/10/20 12:31:28

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:

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.
Lenard
 
Posts: 2283
Joined: 2005/11/29 02:35:25
Location: Indiana

Re: Installing Sun Java JDK for Users

Postby Mabus » 2006/10/21 10:02:55

Thank you very much, works like a charm now.

You rock!
Mabus
 
Posts: 2
Joined: 2006/10/20 01:06:40

Re: Installing Sun Java JDK for Users

Postby Lenard » 2006/10/22 01:05:22

Your welcome, glad to help.

Enjoy ;)
Lenard
 
Posts: 2283
Joined: 2005/11/29 02:35:25
Location: Indiana

Re: Installing Sun Java JDK for Users

Postby smoge » 2006/12/21 17:06:37

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
smoge
 
Posts: 1
Joined: 2006/12/21 17:01:46

Re: Installing Sun Java JDK for Users

Postby CentOS_beginner » 2007/01/19 22:38:10

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 [~]#
CentOS_beginner
 
Posts: 9
Joined: 2007/01/19 22:11:30

Re: Installing Sun Java JDK for Users

Postby Lenard » 2007/01/20 00:46:19

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
Lenard
 
Posts: 2283
Joined: 2005/11/29 02:35:25
Location: Indiana

Re: Installing Sun Java JDK for Users

Postby CentOS_beginner » 2007/01/20 18:41:42

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.
CentOS_beginner
 
Posts: 9
Joined: 2007/01/19 22:11:30

Re: Installing Sun Java JDK for Users

Postby Lenard » 2007/01/20 19:38:32

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.
Lenard
 
Posts: 2283
Joined: 2005/11/29 02:35:25
Location: Indiana

Re: Installing Sun Java JDK for Users

Postby CentOS_beginner » 2007/01/20 19:53:46

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

# 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=
CentOS_beginner
 
Posts: 9
Joined: 2007/01/19 22:11:30

Next

Return to CentOS 4 - Software Support

Who is online

Users browsing this forum: No registered users and 2 guests