Install Oracle Java

Debian, Ubuntu, etc.

Install Oracle Java 1.7

# add ppa repository
sudo add-apt-repository ppa:webupd8team/java
sudo apt update

# install java
sudo apt install oracle-java7-installer

# set as default
sudo apt install oracle-java7-set-default

Install Oracle Java 1.8

# add ppa repository
sudo add-apt-repository ppa:webupd8team/java
sudo apt update

# install java
sudo apt install oracle-java8-installer

# set as default
sudo apt install oracle-java8-set-default

CentOS, RedHat, etc.

Install Oracle Java 1.7

# install JRE
wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/7u79-b15/jre-7u79-linux-x64.rpm"
sudo yum localinstall jre-7u79-linux-x64.rpm

# install JDK
wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/7u79-b15/jdk-7u79-linux-x64.rpm"
sudo yum localinstall jdk-7u79-linux-x64.rpm

Install Oracle Java 1.8

# install JRE
wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" \
"http://download.oracle.com/otn-pub/java/jdk/8u60-b27/jre-8u60-linux-x64.rpm"

sudo yum localinstall jre-8u60-linux-x64.rpm
# install JDK
wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u60-b27/jdk-8u60-linux-x64.rpm"
sudo yum localinstall jdk-8u60-linux-x64.rpm

Set default java

a) Using alternatives

sudo alternatives --config java

Sample output:

There are 3 programs which provide 'java'.

  Selection    Command
-----------------------------------------------
*+ 1           /usr/lib/jvm/jre-1.7.0-openjdk.x86_64/bin/java
   2           /usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/java
   3           /usr/java/jdk1.8.0_60/jre/bin/java

Enter to keep the current selection[+], or type selection number: 

If the java version you want to use is not displayed then we need to add it to alternatives:

alternatives --install /usr/bin/java java /usr/java/jdk1.8.0_60/bin/java 22
alternatives --install /usr/bin/javaws javaws /usr/java/jdk1.8.0_60/bin/javaws 22
alternatives --install /usr/bin/javac javac /usr/java/jdk1.8.0_60/bin/javac 22
alternatives --install /usr/bin/jar jar /usr/java/jdk1.8.0_60/bin/jar 22
alternatives --install /usr/bin/javadoc javadoc /usr/java/jdk1.8.0_60/bin/javadoc 22
alternatives --config java
alternatives --config javaws
alternatives --config javac
alternatives --config jarTODO

b) Using environment variables

Many applications use JAVA_HOME or JRE_HOME environment variables to determine the installed location.

If you want the JAVA_HOME environment variable to be set for all users add the following line to ‘/etc/environment’ file.
export JAVA_HOME=/usr/java/jdk1.8.0_60/jre

An easy way to append it to the files is to run this command:

sudo sh -c "echo export JAVA_HOME=/usr/java/jdk1.8.0_60/jre >> /etc/environment"

September 19th, 2017

Posted In: tutorials

Tags: , , , ,

Leave a Comment

Ref:

 

Configure local user info:
git config --global user.name "John Doe"
git config --global user.email "johndoe@example.com"

 

Create repository:
git init --bare --shared foo.git initialized empty shared Git repository in foo.git

If you access your Git repository over http: or https: URLs
git  update-server-info

Now change group access to repository (linux)
chgrp -R <group name> foo.git

 

Create local repository:
git init
git add <file>
git commit -a -m 'Added something'

Then make the link to the shared repository
git remote add origin <user>@<host>:/<repository path>/foo.git

We push to the remote repository
git push origin master

 

Clone existing repository (ssh):
git clone <user>@<host>:/<repository path>/foo.git

 

Working with git:

Show local repository status
git status

Show remote branches
git branch -r

Checkout remote branch
git checkout -t origin/<branch name>

Checkout remote tag
git checkout tags/<tag_name>

Switch local branches
git checkout <branch name>

Update local branch
git pull origin <branch name>

Update remote branch with local commits
git push origin <branch name>

Commit changes in local branch
git add <file> ...
git commit -m "<message>"
or commit all modified files
git commit -a -m "<message>"

Revert local changes (reset)
git reset --soft HEAD
git reset --mixed HEAD
git reset --hard HEAD

Working with remotes
git remote

Delete tag
git tag -d 12345
git push origin :refs/tags/12345

December 1st, 2014

Posted In: tutorials

Tags:

Leave a Comment