How To Install libhtmlunit-java on Ubuntu 18.04

In this tutorial we learn how to install libhtmlunit-java on Ubuntu 18.04. libhtmlunit-java is GUI-Less browser for Java programs

Introduction

In this tutorial we learn how to install libhtmlunit-java on Ubuntu 18.04.

What is libhtmlunit-java

libhtmlunit-java is:

HtmlUnit is a “GUI-Less browser for Java programs”. It models HTML documents and provides an API that allows you to invoke pages, fill out forms, click links, etc… just like you do in your “normal” browser.

It has fairly good JavaScript support (which is constantly improving) and is able to work even with quite complex AJAX libraries, simulating either Firefox or Internet Explorer depending on the configuration you want to use.

It is typically used for testing purposes or to retrieve information from web sites.

HtmlUnit is not a generic unit testing framework. It is specifically a way to simulate a browser for testing purposes and is intended to be used within another testing framework such as JUnit or TestNG.

There are three methods to install libhtmlunit-java on Ubuntu 18.04. We can use apt-get, apt and aptitude. In the following sections we will describe each method. You can choose one of them.

Install libhtmlunit-java Using apt-get

Update apt database with apt-get using the following command.

sudo apt-get update

After updating apt database, We can install libhtmlunit-java using apt-get by running the following command:

sudo apt-get -y install libhtmlunit-java

Install libhtmlunit-java Using apt

Update apt database with apt using the following command.

sudo apt update

After updating apt database, We can install libhtmlunit-java using apt by running the following command:

sudo apt -y install libhtmlunit-java

Install libhtmlunit-java Using aptitude

If you want to follow this method, you might need to install aptitude first since aptitude is usually not installed by default on Ubuntu. Update apt database with aptitude using the following command.

sudo aptitude update

After updating apt database, We can install libhtmlunit-java using aptitude by running the following command:

sudo aptitude -y install libhtmlunit-java

How To Uninstall libhtmlunit-java on Ubuntu 18.04

To uninstall only the libhtmlunit-java package we can use the following command:

sudo apt-get remove libhtmlunit-java

Uninstall libhtmlunit-java And Its Dependencies

To uninstall libhtmlunit-java and its dependencies that are no longer needed by Ubuntu 18.04, we can use the command below:

sudo apt-get -y autoremove libhtmlunit-java

Remove libhtmlunit-java Configurations and Data

To remove libhtmlunit-java configuration and data from Ubuntu 18.04 we can use the following command:

sudo apt-get -y purge libhtmlunit-java

Remove libhtmlunit-java configuration, data, and all of its dependencies

We can use the following command to remove libhtmlunit-java configurations, data and all of its dependencies, we can use the following command:

sudo apt-get -y autoremove --purge libhtmlunit-java

References

Summary

In this tutorial we learn how to install libhtmlunit-java package on Ubuntu 18.04 using different package management tools: apt, apt-get and aptitude.