Create Scala Project with Maven in IntelliJ Idea

Every Scala developer out there knows SBT is the default build tool for Scala but there may be some situations limiting you to stick with the famous build tool for Java: Apache Maven. Haven't come across a reason to use Maven for Scala projects yet? Keep using SBT. However, if your team decides to use Apache Maven because it works well with their CI server or because they have a well-established development environment with Apache Maven, you have no choice and this article is here to help you.
Create Scala with Maven Project in IntelliJ Idea
Creating a Scala project using Apache Maven in the command-line is easy. Just run the following command, answer the questions in the interactive shell and you are good to go. Install Apache Maven on Linux to run mvn from the terminal.
mvn archetype:generate -DarchetypeGroupId=net.alchim31.maven -DarchetypeArtifactId=scala-archetype-simple
However, why should we switch to the terminal just to create a project and then switch back to the IntelliJ Idea and import the project to continue the development? In this article, you will see how to prepare your IntelliJ Idea to create Scala projects with Apache Maven.
Read More

Install Oracle JDK 16 on Linux

Even though OpenJDK is available in Linux repositories, some applications strictly require Oracle Java Development Kit. This article shows you how to manually install Oracle JDK $java_version on your Linux system. This article uses JDK $java_version$java_update_no to demonstrate the installation. In the provided commands, replace the version specific paths and file names according to your downloaded version.

Install Oracle JDK $java_version on Linux

Oracle provides deb and rpm installers
If your Linux distribution is using DEB package format like Debian, you can download and install the jdk-$java_version$java_update_no_linux-x64_bin.deb file using the following command:
sudo dpkg -i jdk-$java_version$java_update_no_linux-x64_bin.deb
If your  Linux distribution is using RPM package format like Cent OS, you can download and install the jdk-$java_version$java_update_no_linux-x64_bin.rpm file using the following command:
sudo rpm -ivh jdk-$java_version$java_update_no_linux-x64_bin.rpm

However, this article explains the manual installation method which is applicable for all Linux distributions out there. Personally, I prefer the manual installation because I have more control over the changes made in the system.

Read More

Download Files in Android - Kotlin & Java

Unless you are writing a Download Manager, downloading files in an Android application is never going to be the main business logic to solve but based on the requirement, you may need to download metafiles, media files, or documents over the Internet within your Android application. However, a reliable solution to download files in an Android application poses its own challenges including but not limited to the following list:

1. Thread Management

IO operations must be executed in a separate thread. Though there are plenty of options to achieve this such as now deprecated AsyncTask, Kotlin coroutines, or RxJava, still complex for a novice developer to properly handle the concurrency problems. Sending signals to the downloading thread to cancel or pause the download may introduce additional synchronization issues.

2. Error Handling

What if the Internet connection dropped while downloading the file? What if the application is closed while downloading/saving the file? How to handle all HTTP errors? the list goes on. Addressing all these scenarios is tedious and most of the time not possible.

3. Updating the UI

While downloading the file in a separate thread, updating a progress bar in the main thread is a challenge unless the concurrency framework you use provides an easy way. The same goes to update the UI after the file is downloaded.

Read More

Contact Form


Email *

Message *