Install latest Java 8 on raspbian

I’m always looking for this commands when I need to install latest Java 8 JDK on my RPi, so I’m adding them here just in case I’ll need to use them again.

Unfortunately default Raspbian repository contains old Java version 1.8.0_65-b17 while the latest (when I’m writing this post) is 1.8.0_151-b12.

Installation

First install dirmngr:

 sudo apt-get install dirmngr

Second add deb repositories and key:

echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" | sudo tee /etc/apt/sources.list.d/webupd8team-java.list
echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" | sudo tee -a /etc/apt/sources.list.d/webupd8team-java.list
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys EEA14886

Warning! If you add xentail repositories (as many RPi forums and other pages state) you’ll end up with old 1.8.0_65 version, you must be using trusty repositories in order to install latest Java version.

Update repositories:

sudo apt-get update

Install Java installer:

 sudo apt-get install oracle-java8-jdk 

Verify Java version

To be 100% sure I have proper version of Java I use basic command:

java -version

Remove old Java

In case you have old Java 8 JDK

sudo apt-get remove --purge oracle-java8-jdk

Sources

Remove Java
Default Java installation
trusty repositories of Java 8 JDK

Colors in git diff

When I use git a diff function is really useful but by default it displays VT100 commands instead text coloring. This is solution how to enable colors in git diff.

Solution:

add this line to your ~/.cshrc.user

setenv LESS -R

and source that file:

source ~/.cshrc.user

sed in-place – find and replace string in all files

Sed is a really powerful and useful linux program when you want to replace certain string in a file.
But it gets harder when you wan replase srting in all available files in directory .
Here is the solution with sed in-place command:

find /home/user/mydir -type f -exec sed -i 's/oldstring/newstring/g' {} \;

Useful links:

http://linux.about.com/od/commands/l/blcmdl1_sed.htm

Source:

http://www.brunolinux.com/02-The_Terminal/Find_and%20Replace_with_Sed.html

Create and extract tar.gz files on any Linux

I allways forget how to extract a *.tar.gz file from command line on Linux, so I have to write it down.

Example of extract tar file:

tar -xvf file.tar.gz

Where:
x extract
v verbose output (prints all extracted files)
f specify input filename
z decompress

Example of creating archive with tar:

tar -cvzf compressed_file.tar /path/to/directory

Where:
c create archive
v verbose output
f specify output filename
z compress

Other examples:
Create compressed archive with three files from separate directories:

tar -cvzf compressed_file.tar /path/to/file1 /path/to/file2 /path/to/file3

Czytaj więcej