This article will open a series of manuals on how to setup an automation testing environment using the latest at the moment Ubuntu 20.04 Linux, Current JDK 11 LTS, Latest Maven, Latest JUnit and IntelliJ Community IDE.

Preconditions: This article assumes that you have Ubuntu 20.04 installed and updated with all the latest updates. You also should have sudo privileges to be able to install the software.

Part 1 – Install JDK:

The simplistic way: Open JDK is available to install using apt, open your terminal and execute:

user@ubuntu:~$ sudo apt install default-jdk

Follow the installation procedure. It’s straightforward and usually doesn’t have any issues along the way. Post install verification can be found right after alternative installation methods below, because it’s pretty much the same for all of them. Click to here to get to that part.

Alternative Installation 1: Download from Oracle and install the package manually.

DL link: https://www.oracle.com/java/technologies/javase-jdk11-downloads.html

Take: jdk-11.0.7_linux-x64_bin.deb

Sign In to Oracle and Download will start automatically.

As a result you should get a package: jdk-11.0.7_linux-x64_bin.deb

Now let’s open terminal and execute this command:

user@ubuntu:~$ cd ~/Downloads   //  .deb file should be there

user@ubuntu:~$ sudo apt install ./jdk-11.0.7_linux-x64_bin.deb

This should install the package in your system. Now we’ll need to make java and javac available to the system. For that we need to execute 2 commands:

user@ubuntu:~$ sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk-11.0.7/bin/java 1

And:

user@ubuntu:~$ sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk-11.0.7/bin/javac 1

After that continue with Post install verification – click to here to get to that part.

Alternative Installation 2: Amazon Corretto

Downloads for Amazon Corretto are available here: https://docs.aws.amazon.com/corretto/latest/corretto-11-ug/downloads-list.html

Direct link to Java 11 JDK: https://corretto.aws/downloads/latest/amazon-corretto-11-x64-linux-jdk.deb

This should download Java 11 JDK package: java-11-amazon-corretto-jdk_11.0.7.10-1_amd64.deb

The installation is easier than Oracle JDK, let’s do it, open the terminal and type:

user@ubuntu:~$ cd ~/Downloads // .deb file should be there

user@ubuntu:~$ sudo apt install ./java-11-amazon-corretto-jdk_11.0.7.10-1_amd64.deb

This should install the Amazon Correto JDK in your system. Continue with Post installation verification below:

Post installation verification

Now after JDK installation is completed we need to verify that everything works:

user@ubuntu:~$ java -version

The result should look something like:

openjdk version "11.0.7" 2020-04-14
OpenJDK Runtime Environment (build 11.0.7+10-post-Ubuntu-3ubuntu1)
OpenJDK 64-Bit Server VM (build 11.0.7+10-post-Ubuntu-3ubuntu1, mixed mode, sharing)

And to see what do we have for the compiler execute:

user@ubuntu:~$ javac -version

Expected result:

javac 11.0.7

Setting up $JAVA_HOME

This part is following the Open-JDK installation. Make sure you pay attention to your paths for Alternative installations.
Now we’ll need to verify that $JAVA_HOME variable exist. Many parts of this setup depend on this variable. If this is your first install for JDK it most likely isn’t there. So we’ll need to setup the variable like so:

Short way:

This way should work, but if it doesn’t there is an alternative below. In your terminal type:

user@ubuntu:~$ readlink -f $(which java)

The expected result should look like this below. That’s a full Java path in your system:

/usr/lib/jvm/java-11-openjdk-amd64/bin/java

For our $JAVA_HOME we’ll need this part of the path:

/usr/lib/jvm/java-11-openjdk-amd64

If that somehow didn’t work, there’s an alternative. See below.

Long way:

Type this in the terminal:

user@ubuntu:~$ whereis java

The reply should look like this:

java: /usr/bin/java /usr/share/java /usr/share/man/man1/java.1.gz

Now, let’s start digging, type this:

user@ubuntu:~$ ls -l /usr/bin/java

Oh, that’s a symbolic link… let’s dig deeper:

user@ubuntu:~$ ls -l /etc/alternatives/java

Reply should be looking like so:

lrwxrwxrwx 1 root root 43 Apr 24 05:02 /etc/alternatives/java -> /usr/lib/jvm/java-11-openjdk-amd64/bin/java

For our $JAVA_HOME we’ll need this part of the path:

/usr/lib/jvm/java-11-openjdk-amd64

Now let’s setup the $JAVA_HOME environment variable with the path we located.

user@ubuntu:~$ export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64

Then verify it’s there:

user@ubuntu:~$ echo $JAVA_HOME

Returns:
/usr/lib/jvm/java-11-openjdk-amd64

And this is the result we are looking for!

Adding $JAVA_HOME to $PATH.

To add $JAVA_HOME to the $PATH we need to type this in the terminal:

/home/user$ export PATH=$PATH:$JAVA_HOME/bin

Those variables will last until bash is running, if you close terminal or restart your computer they’re going to be lost. So, we need to make those changes permanent, we need to open current user’s home folder:

user@ubuntu:~$ cd ~

Then open nano editor(I prefer nano because it’s easy to use) and edit the file .bashrc which is hidden file in current user’s folder.

user@ubuntu:~$ nano .bashrc

And under comments starting with # we need to add these line:

export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64

Now after machine restarts we should be able to see $JAVA_HOME every time we try to access it.

user@ubuntu:~$ echo $JAVA_HOME

Replies with:
/usr/lib/jvm/java-11-openjdk-amd64

We are done with JDK setup! Congrats!

Probably a month or so ago I found one interesting idea. If a person wants to learn something new, they should look at different sources at the same time or one right after another. I began my Java language journey at Lynda.com but it went from simple to not so simple 🙂 really quick there. So I was looking for another source about Java that would clarify more details for me. And stumbled upon this book. So it’s kinda old school – a book. This means I had to compare my experiences from book vs from video. Mine is just like this one(see the image below). But hard copy. Loved the book and author’s approach to teaching. Was nice to learn some Java unrelated things too 🙂

So, my journey continues… This one was big and interesting and took a little while to complete. But it gave me a good boost in understanding OOP concepts. And overall Java applications structure. Definitely a good one. I can recommend this one to anybody.

So, recently I decided to start learning Java! This sounds like a good thing to have an Automation testing skills nowadays. I do automation testing for Windows applications but this is a very specific thing. And for web automation the most common language would be Java. That’s why I chose that one.

There’s an amazing course available for Java learners at Lynda.com Here

Some completion certs earned on the way to Java Programmer!

This weekend, I discovered an e-mail from the Codeschool in my Promotions mail box, it said: Free weekend at the Codeschool. So, I decided to take this opportunity and refresh my SQL skills. I took two courses and passed them successfully.

Here are my completion badges:

codeschool-badges

Thanks to the Codeschool.com for this opportunity. I must say, those two courses were the best I’ve ever taken so far.

Direct links to those courses:

The TrySQL course and The Sequel to SQL course

I started to learn Python about a month ago, and today I asked my fellow student at BBST Foundations course if he could recommend any good books to learn Python. He’s an experienced Python programmer. So, he gave me a great list of books. I wish to keep that list for myself and share it with others:

– Effective Python (more advanced)

– Learning Python, 5th Edition – very comprehensive and deep going introduction

– Programming Python, 4th Edition

– Python Testing Cookbook (2011) – nice for testing

– Test-Driven Development with Python – also very interesting book but requires more knowledge of Python

– Testing Python – good for Unit tests, BDD and TDD programming approaches

– Learning Python the Hard Way -> http://learnpythonthehardway.org/ very fast way to get basic knowledge

– 100 Python Programming Exercises – good for practice https://github.com/zhiwehu/Python-programming-exercises/blob/master/100%2B%20Python%20challenging%20programming%20exercises.txt

– Project Euler – more practice more mathematical exercises – https://projecteuler.net/

Thanks, Patrick!