Install JDK on Ubuntu in 6 Steps

The Java Development Kit (JDK) is an implementation of either one of the Java Platform, Standard Edition, Java Platform, Enterprise Edition, or Java Platform, Micro Edition platforms released by Oracle Corporation in the form of a binary product aimed at Java developers on Solaris, Linux, macOS or Windows.The JDK includes a private JVM(Java Virtual Machine) and a few other resources to finish the development of a Java Application

We need JDK because it is a bundle of software components that is used to develop Java based applications and it includes JRE , the compilers and tools (like JavaDoc, and Java Debugger) to create and compile programs.

To install it on Ubuntu we need to follow some steps : –

Step 1-First of All we need to download JDK file using this link  (Don’t forget to Accept License Agreement) and Download bin.tar.gz file

Step 2– Now go to terminal (Ctrl + Alt + T) then go to where file is downloaded in my case

$ cd ~/Downloads/

Step 3– Now to extract use command

$ sudo tar xvzf jdk-10_linux-x64_bin.tar.gz -C /installDirectory

Step 4– Now we have to add Oracle JDK 10 to  PATH environment variable. Otherwise we will have to specify the full path when we run the Oracle JDK 10 commands.

To add Oracle JDK 10 to  PATH environment variable, we need to create a new file in /etc/profile.d with the following command:

so use any editor in my case i am using “nano”

$ sudo nano /etc/profile.d/

Step 5– Add following lines in (Don’t forget to enter your directory where you have installed JDK in place of installDirectory) after this press cntrl + X ( ^X ) then Enter y

export JAVA_HOME="installDirectory/jdk-10"
export PATH="$PATH:${JAVA_HOME}/bin"


Step 6– Now you have to restart your computer for the changes to take effect and to check JDK correctly installed use these commands

$ echo $JAVA_HOME
$ echo $PATH
$ java -version

That’s all these are the 6 steps to install JDK on Ubuntu

Safe Off Switch to Power Down Your Raspberry Pi

Some time it is hard to find solution for raspberry pi.

This time we are solving issue : how to Power Down Your Raspberry Pi using GPIO.


copy script from


sudo apt install python3-gpiozero

#connect button GPIO 21 and GND

#run below command to test


# hold button(gpio21 and GND) for 2 second . your pi will be shutdown.

If it is ok then power on your pi3 again


Now execute your script ,when raspberry pi power on every time.

sudo nano /etc/rc.local

in rc.local file at the end your code must be look like this

python3 /home/pi/ &

exit 0     

Thats it now . restart your pi again and test it….

Adding GPS tracking to your Raspberry Pi-based projects

Hi geeks some time it is hard to manage gps connection to Raspberry PI.

dont worry we need following item needs for connectivity

  1. Raspberry pi 3
  2. USB to TTL adapter (Prolific PL2303)
  3. Neo 6M-0-001 Ublox GPS Module


Connect your GPS module to USB to TTL adapter(Tx and Rx cross connection Required dont get confused)

GPS Module USB to TTL adapter
5v 5v
VCC 5v
Rx Tx
Tx Tx


connect USB to TTL adaptor to raspberry pi and login to raspberry pi using putty or terminal.


Now run following command to detect usb to ttl

ls /dev/ttyUSB*
sudo lsusb

I am assuming that USB to TTL connected on /dev/ttyUSB0. so run following command to get data from GPS.

sudo cat /dev/ttyUSB0

you will get data like above screenshot.Ctrl+C to stop output.

Optional Steps

Step 3

Installing a GPS Daemon (gpsd)
sudo apt-get install gpsd gpsd-clients python-gps

The next step is installing some software on your Raspberry Pi that understands the serial data that your GPS module is providing via /dev/ttyUSB0.

then run

//this command with tell actual gps data
gpsmon /dev/ttyUSB0

sudo gpsd /dev/ttyUSB0 -F /var/run/gpsd.sock

above will run gps data service in background

now see the data

cgps -s


article source 


How to Install Ubuntu


Ubuntu is an open source operating system for computers. It is a Linux distribution based on the Debian architecture. It is usually run on personal computers, and is also popular on network servers, usually running the Ubuntu Server variant, with enterprise-class features. Ubuntu runs on the most popular architectures.

Things That Ubuntu Does Better Than Windows

1- Ubuntu is different. Everything is done via repositories and it uses a dedicated update manager to update both the operating system and all of the applications installed. So you only ever have to manage your updates from one place.

2-Ubuntu is also a lot less popular than Windows. That means that the bad guys who make all the viruses don’t really care about it, so they don’t bother writing much malware for Ubuntu: that’s great news for us users!

3-Desktop customization is also cool in Ubuntu there are several themes available over the internet

4-We can also use as a live environment

5-Ubuntu is 100% free. It won’t cost you a penny (although you can make a donation on their download page)

Bootable pen drive for ubuntu ?

Firstly visit above link and download ubuntu ISO file and make bootable pen-drive ( U can use softwares like powerISO ,unetbootin and in ubuntu u can use Startup disk creater) Now there are two options if u wants to use as a live environment then TRY UBUNTU option otherwise INSTALL UBUNTU

Use something else if u wants to customize partitions then click on install now button after that

Swap Area ( Linux-swap)

Swap space in Linux is used when the amount of physical memory (RAM) is full. If the system needs more memory resources and the RAM is full, inactive pages in memory are moved to the swap space. While swap space can help machines with a small amount of RAM, it should not be considered a replacement for more RAM.

For more modern systems (>1GB), your swap space should be at a minimum be equal to your physical memory (RAM) size “if you use hibernation”, otherwise you need a minimum of round(sqrt(RAM)) and a maximum of twice the amount of RAM

Now proceed according to instructions . . .

Finally Ubuntu is installed on your system

How to create Barcodes in python

What is a Barcode?

barcode is an optical, machine-readable , representation of data , the data usually describes something about the object that carries the barcode . Traditional barcodes systematically represent data by varying the widths and spacings of parallel lines, and may be referred to as linear or one-dimensional (1D) ,we can quickly test on console (mac, tested on ubuntu , debian).

PyBarcode ships with a little commandline script to generate barcodes without knowing Python. The install script detects your Python version and adds the major version number to the executable script. On Python 2 it is called pybarcode2 and on Python 3 pybarcode3. When installing in a systemwide direction, you can have pyBarcode installed in Python 2 and 3 at the same time without trouble.


  • Setuptools/distribute for installation (new in version 0.7beta4)
  • Python 2.6 or above (including Python 3.x)
  • On Python 2.6, 3.0, 3.1: argparse (for the commandline script)
  • Program to open SVG objects (your browser should do it)
  • Optional: PIL to render barcodes as images (PNG, JPG, …)


Make sure you have setuptools/distribute installed.

Unpack the downloaded file, cd into the pyBarcode directory and run python install. Or just copy the barcode dir somewhere in your PYTHONPATH.

The best way is to use pip:

pip install pyBarcode

Provided Barcodes

EAN-8, EAN-13, UPC-A, JAN, ISBN-10, ISBN-13, ISSN, Code 39, PZN


Usage form command line

pybarcode{2,3} create “My Text” barcodename

If you know which python version your system have then run accordingly.I am assuming python3.x

pybarcode{2,3} create -t png "My Text" outfile


pybarcode3 create "My Text" outfile


Sample example to generate QR code and save in svg file in python.


ean13 is EAN or European Article Number and 13 representing it is 13 digit number

>>> import barcode
>>> ean = barcode.get('ean13', '123456789102')
# Now we look if the checksum was added
>>> ean.get_fullcode()
>>> filename ='ean13')
>>> filename
>>> options = dict(compress=True)
>>> filename ='ean13', options)
>>> filename

Now we have ean13.svg and the compressed ean13.svgz in our current working directory. Open it and see the result.


To generate barcodes as images, you must provide the ImageWriter to the get function. Without any options, the images are rendered as PNG.

>>> import barcode
>>> from barcode.writer import ImageWriter
>>> ean = barcode.get('ean13', '123456789102', writer=ImageWriter())
>>> filename ='ean13')
>>> filename


source :

join our python training in kanpur for Zero to Hero in Python.

How to create QR code in Python

What is a QR Code in nutshell?

A Quick Response code is a two-dimensional pictographic code used for its fast readability and comparatively large storage capacity. The code consists of black modules arranged in a square pattern on a white background. The information encoded can be made up of any kind of data (e.g., binary, alphanumeric)

its very simple on console (tested on mac, debian and ubuntu latest OS)

below command will install all required module including pil (Python Imaging Library):pillow

pip install qrcode[pil]


Usage form command line

qr "Some text" > image_name_with_extention
qr "" > msk.png


Sample example to generate QR code and save in png file in python.

import qrcode
qr = qrcode.QRCode(


img = qr.make_image(fill_color="black", back_color="white")'msk-site.png') 

Sample example to instant preview of QR code in python.

import qrcode
qr = qrcode.QRCode(
qr.add_data('Some data')

img = qr.make_image(fill_color="black", back_color="white")


source :

join our python training in kanpur for Zero to Hero in Python.