0

I am installing java to my Linux machine. Downloading the jre and jdk and extracting them did not help only - I assume some environmental variables are also needed. What all path variables are needed to be set? With which values? Expecting the java installs itself to <installation-dir>?

8
  • Which Linux distro are you using?
    – trojanfoe
    Jun 1, 2011 at 8:18
  • 1
    This question is not programming related. Should be moved to SF, SU, Linux or Ubuntu.
    – Tim Büthe
    Jun 1, 2011 at 8:19
  • 2
    should probably be on unix.stackexchange.com Jun 1, 2011 at 8:19
  • @Tim Bûthe, @tobyodavies: for my point of view coding starts from setting up the environment. Actually I got the answer and that satisfied me.
    – mico
    Jun 1, 2011 at 8:24
  • @Mikko Setälä: I'm glad you got yours answer, that's great. But setting up the environment has little to do with actually programming. Following that logic, you could ask "which operating system should I use", or "are you more productive in the morning" and so on...
    – Tim Büthe
    Jun 1, 2011 at 9:31

4 Answers 4

2

Depending on your distribution it may be easiest to install from your package manager. On Ubuntu, for example, you can do:

sudo aptitude install open-jdk

Otherwise, usually the sun (oracle) version of java comes with a .bin file which you need to make executable and run as root in order to get java properly installed.

You shouldn't need to set any environment variables to get java to work, although some applications will require you to set JAVA_HOME, JDK_HOME and/or JRE_HOME to point to the java install's bin directory. You can see where your java install is by looking at where the symlink from

/etc/alternatives/java

points.

2
  • How to see symlink content? morecommand says this is not a text file and I can't get up with another command in mind.
    – mico
    Jun 1, 2011 at 8:32
  • You can look at a symlink with ls -atl which will give you all the details about it. It will have an -> which points to the target of the link. Also, readlink will do it :)
    – Richard J
    Jun 1, 2011 at 8:41
2

Most Linux systems use the Gnu Java implementation by default and don't change this if you install an additional JDK. Therefore you need to explicitly make your new Java installation the default Java to be used. You can do so by running sudo update-alternatives --config java.

If you prefer graphical configuration, you can install the "galternatives" package, which lets you configure all those application defaults in a nice little UI.

1
  • This is the easiest and most preferable way, if more than one Java is installed by package management.
    – Balin
    Jan 6, 2023 at 10:38
2

You just need to make /usr/bin/java point to the java executable in the directory where you had extracted the JRE/JDK.

If you extracted it to, say, /opt/jdk1.6.0_23/bin/java, then you need to create a link like this:

sudo ln -s /opt/jdk1.6.0_23/bin/java /usr/bin/java

Prior to this, you can choose to backup an old java installation by:

sudo mv /usr/bin/java /usr/bin/java_old

Here is how I installed JRE: Install Sun Java Runtime.

0
1

Get the jdk for linux. Go to the root Directory. Use the following commands to install.

./configure make make install

PATH .= New Path where Java is installed.

To go to the root directory for UBUNTU use command "sudo". For FEDORA use "su".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.