1

Maybe this is a simple question.

I don't find the explanation of the commands for install Java JDK and JRE

I downloaded the jdk-7u5-linux-x64.tar.gz and jre-7u5-linux-x64.tar.gz, I extracted these files and then moved to /usr/lib/jvm/. Whell I guess that the name /jvm (I created that beacause I don't had it) is not important beacause the installation is by link.

Most webs tell me that I have write that but they not explain why.

I guess that this create a java's link in /usr/bin/

/usr/bin/java -> /etc/alternatives/java -> /usr/lib/jvm/jdk1.7.0_05/bin/java

sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.7.0/bin/java 1

/usr/bin/java ==================> is the final link

java ========================> I don't understand why I have to write that

/usr/lib/jvm/jdk1.7.0_05/bin/java ==> original file

1 ===========================> why 1? some people write 2, 3 or I saw 2000!

the same in java, javac and javaws. And the same in JRE, but when I install JRE, th link is replaced

sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jre1.7.0/bin/java 2

and when I choose sudo update-alternatives --config java I can only choose one, so what is the difference between jdk/bin/java and jre/bin/java (they are the same version)

Can anyone explain me that in a simple way? because I'm beginner in that, I don't know nothing of java, I only need these javas for other program that use it

Can anyone send me a good page for the correct installation of both, please.

Thanks

1
  • You should make @Samik 's answer to be the correct answer. Not only unfair you did not but you won't be able to help others because of it. Also, it isn't cool that he took the time to answer you ans that you didn't even thanked him. You also make people think you weren't answered and take their time to open your question in hope they can answer you.
    – José
    Sep 12, 2016 at 12:45

1 Answer 1

2

Check the man page of update-alternatives with man update-alternatives. The options are nicely explained there.

The Debian alternatives system is an interface between command used by an user for a particular function and the command chosen by system administrator for that functionality. This is a way by which admin can change the underlying command for that function without interfering with the command used by the user. Suppose an user use the command editor to edit a file and admin links the command to vi with update-alternatives via /etc/alternatives/editor; then a better editor vim becomes available and admin changes the link to vim, the user will still be able to edit a file with editor command.

The syntax is

update-alternatives --install link name path priority

  • link = master command for user's use (e.g. /usr/bin/java which is accessible with just java because /usr/bin is searched for any commands by default)
  • name = name of the intermediate link under /etc/alternatives directory working as the interface between user's command and actual command(e.g. java which creates /etc/alternatives/java; user's command /usr/bin/java points to it. This is why you have to write java)
  • path = actual command set by administrator(e.g. /usr/lib/jvm/jdk1.7.0/bin/java; /etc/alternatives/java links to it)
  • priority = the command used by default, this is set by admin(e.g. 1 for highest priority or default, 2 for next highest priority and so on)

So, with this settings if you have more than one java installation, e.g. OpenJDK and Oracle's JDK then you can choose between them while keep using java as the command as an user and by setting the priority with update-alternatives --config java as administrator, which is actually changing the link between /etc/alternatives/java and the actual java program.

There is actually no difference between JDK's java and JRE's java. In fact in a JDK installation JDK's java is a symbolic link to JRE's java.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .