LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   What is the difference between GCJ and jre? (https://www.linuxquestions.org/questions/linux-newbie-8/what-is-the-difference-between-gcj-and-jre-806269/)

pinga123 05-06-2010 05:23 AM

What is the difference between GCJ and jre?
 
I was trying to install jdk and jre latest version on my linux machine .

Oracle enterprise linux

However after successful install of jdk and jre i came across a strange thing that whenever i used to fire java -version
i used to get following output
Quote:

java
Usage: gij [OPTION] ... CLASS [ARGS] ...
to invoke CLASS.main, or
gij -jar [OPTION] ... JARFILE [ARGS] ...
to execute a jar file
Try `gij --help' for more information.
But after few tweaking into my system i somehow managed to get the latest java running.

But now i m confused what was the previous output referring to and why was it there?

knudfl 05-06-2010 06:23 AM

The default installed java is the "gcc - java".
( Please Google it for more information.)


The easy "setting up solution" :
su
Code:

/usr/sbin/alternatives --install /usr/bin/java java /usr/java/jdk1.6.0_20/bin/java 2
And then you can do :
/usr/sbin/alternatives --config java
........ and choose '2'.

'javac' seems to be set up at the rpm package install.
http://www.linuxquestions.org/questi...8/#post3959048
java -version
javac -version
..

PMP 05-06-2010 06:34 AM

gij - GNU interpreter for Java

This comes default with EL.
Put your newly installed java before the path of gij.

pinga123 05-06-2010 11:51 PM

Quote:

Originally Posted by knudfl (Post 3959130)
The default installed java is the "gcc - java".
( Please Google it for more information.)


The easy "setting up solution" :
su
Code:

/usr/sbin/alternatives --install /usr/bin/java java /usr/java/jdk1.6.0_20/bin/java 2
And then you can do :
/usr/sbin/alternatives --config java
........ and choose '2'.

'javac' seems to be set up at the rpm package install.
http://www.linuxquestions.org/questi...8/#post3959048
java -version
javac -version
..

Thank you very much for you reply .

Here is what i had done before reading you post.
i have fired "which java" command.

from the output i have got the location of java file
i changed the java file location from /usr/bin
to /usr/bin/javabackup (created new folder named javabackup).
added /usr/java/jdk<versionname>/bin to path using.
export PATH=$PATH:/usr/java/jdk1.6.0_20/bin/

Is there any thing wrong into it?
Code:

/usr/sbin/alternatives --install /usr/bin/java java /usr/java/jdk1.6.0_20/bin/java 2
Can u please give solution to some of my queries.
1)What does /usr/sbin/alternatives does?
2)Is it distribution specific or for different distribution there is a different way of setting it?
3)What is the significance of 2 after /usr/java/jdk1.6.0_20/bin/java?

ajeetsinghraina 05-06-2010 11:55 PM

Reconfiguring the default Java configuration for Red Hat / Fedora

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/jre1.6.0/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/jre1.6.0/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/jre1.6.0/bin/java - priority 2
Current `best' version is /usr/java/jre1.6.0/bin/java.

Next you might want to create (or edit) /etc/profile.d/java.sh
file, example below;

export JAVA_HOME="/usr/java/jre1.6.0/bin/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/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.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)

That's it, all done.

knudfl 05-07-2010 02:52 AM

"" 1) What does /usr/sbin/alternatives do ?""
→ makes an entry into /etc/alternatives .

"" 2) Is it distribution specific or.. ""
→ Not all 'Linux OS' have /etc/alternatives .

"" 3) What is the significance of 2 ......""
→ An ID for this entry. With 2...4 java installed,
it's a way of indexing them in /etc/alternatives.

The export command, (post #4) is temporary, is valid
for one terminal session only. When you exit the
terminal the temporary path exported exist no more.

I would never set a java path ! When the right java
is present in /usr/bin/ , everything will usually work.
The "/etc/alternative/ system" takes care of that :
A link by name 'java' in /usr/bin/ .
..


All times are GMT -5. The time now is 03:57 PM.