32

I need java 1.7 and server has only got 1.6. I have no root privileges. I tried to google out something but it seems like nobody was doing it. Can I somehow compile it or get ready binaries so I could put those into my PATH. Could you help? System is Redhat.

Pawel Osipowski
  • 514
  • 1
  • 4
  • 8

4 Answers4

51

It is quite easy...

Download the JDK as a tarball from Oracle (a simple google search will yield the link).

Unzip it somewhere in your $HOME (for instance, $HOME/jdk).

Set JAVA_HOME to the path of the root JDK install; then prepend $JAVA_HOME/bin to your PATH.

And off you go.


Here I have a particular setting insofar as I run three different major versions of the JDK: 6, 7, 8. For instance, here is my source file for setting the current shell to use Java 8:

$ cat ~/.jdk/8
export JAVA_HOME=/opt/sunjdk/1.8/current
export PATH="$JAVA_HOME/bin:$PATH"

And in /opt/sunjdk/1.8 (given that /opt/sunjdk is writable by my user hence I don't need to be root):

$ ls -l /opt/sunjdk/1.8/* -d
lrwxrwxrwx 1 fge fge  11 Oct 30 10:09 /opt/sunjdk/1.8/current -> jdk1.8.0_25
drwxr-xr-x 1 fge fge 274 Mar 18  2014 /opt/sunjdk/1.8/jdk1.8.0_05
drwxr-xr-x 1 fge fge 274 Sep 18 02:44 /opt/sunjdk/1.8/jdk1.8.0_25

(and yes, I was root to begin with so as to grant write permissions for /opt/sunjdk to "my" user; if you have no such liberty, just create another directory in your home)

fge
  • 119,121
  • 33
  • 254
  • 329
  • You can do the manual installation as well for OpenJDK. I did not find a download on the site itself, but here www.azul.com/downloads/zulu/zulu-linux/ you'll find the newest OpenJDK as .tar.gz. – David Georg Reichelt Apr 10 '17 at 14:22
6

Oracle offers JRE and JDK also as *.tar.gz for Linux. I usually had success just downloading such a package, untarring/unzipping it (tar -xzvf jdk-8u25.tar.gz) and then running it, using the absolute path.

cello
  • 5,356
  • 3
  • 23
  • 28
6

I was able to accomplish this using conda.

Conda is an open-source package-manager by Anaconda, that according to the website:

You do not need administrative or root permissions to install Anaconda if you select a user-writable install location.

You can search the package repo from a browser at anaconda.org or command line, for example here are the results for JDK.

For Linux, you would download this installer. Here is a command line that will start the installer for convenience:

wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh && bash Miniconda3-latest-Linux-x86_64.sh

Once conda is installed, you can install packages. For example, to install the JetBrains Runtime OpenJDK build:

conda install -c anaconda openjdk

Other builds may be available from other channels in the repository.

The instructions above should give a working install, but the Getting started guide is a good place to get started. Conda uses the concept of environments to help manage versions and paths in a fairly simple and straightforward manner.

I hope this helps someone.

Brian Larsen
  • 612
  • 8
  • 9
1

export JAVA_HOME=/opt/sunjdk/1.8/current
export PATH="$JAVA_HOME/bin:$PATH"

For me this option only worked when I changed linux to use bash instead ksh. I don't know if this is some kind of configuration in my company, but when I tried to run via ksh using "set" command instead "export" to define path, It was set correctly with the path of my new Java installation, but when I typed which java the old version was showed. But, when I executed bash, and typed the "export", it worked. So, if someone have the same problem to configure it using set command, try to use bash with export command. I am using Redhat 6.2.

HarshitMadhav
  • 4,769
  • 6
  • 36
  • 45