Welcome to Knowledge Basement

Linux, Java, Open Source related how-to articles

What are Docker Networks

Docker networks are virtual networks that provide communication channels for Docker containers to communicate with each other and with the host system, allowing containers to communicate securely and efficiently. Docker networks are used to isolate containers from the host system and from other containers, providing a controlled and secure environment for containerized applications. Docker networks… read more »

What is a Port Mapping (Forwarding) in Docker

In Docker, port mapping (also known as port forwarding) is the process of associating a port on the host system with a port on a Docker container, allowing network traffic to be directed to and from the container through the host system’s network interface. Docker containers run in isolated environments with their own network stack,… read more »

What is a Filesystem Mapping in Docker

In Docker, a file system mapping refers to the process of associating a directory or a file from the host system with a directory or a file inside a Docker container. This allows the container to access and manipulate files and directories on the host system, or share files between the host system and the… read more »

How to Properly Use Reflection in Java

Reflection in Java is a mechanism that allows you to inspect and modify the behavior of classes, methods, interfaces, and fields at runtime, even if you do not have access to their source code during compile time. Using reflection, you can access and modify the internal structures of Java objects, examine and modify their fields… read more »

How to Backup and Restore H2 Database

H2Database (or simply H2) is an open-source, lightweight, and fast relational database management system written in Java. It is a pure Java database that can be used as an embedded database, or as a standalone database server. H2Database provides a small footprint (less than 2MB in size), yet it supports SQL and JDBC API, making… read more »

Overusing the Static Keyword in Java

The static keyword is often overused in Java and this can lead to several risks, including: To mitigate these risks, it is recommended to use the static keyword sparingly and only when necessary. It’s important to consider the implications of using static and ensure that it does not negatively impact the maintainability, readability, and testability… read more »

How to Write a Simple Linux Bash Honeypot

The first step in a malicious hacker attack is scanning. This means that an attacker will scan its target for open ports and vulnerabilities. So, the best approach is to block an attacker who tries to do such a scan in the very beginning. Here is a fast and easy way how to do this…. read more »

How to Use Properly Lambdas in Java

Lambdas are a concise way to define and use functional interfaces in Java. Here are some guidelines on how to use lambdas effectively in Java: Here’s an example that demonstrates the use of a lambda expression in Java: import java.util.Arrays; import java.util.List; public class LambdaExample { public static void main(String[] args) { List<String> names =… read more »

What is a Predicate in Java and How to Use It

In Java, a predicate is a functional interface from the java.util.function package that represents a function that takes in one argument and returns a boolean value. The functional interface is defined as: public interface Predicate<T> { boolean test(T t); } The test() method takes in a single argument of type T and returns a boolean… read more »

How to Add Dependencies in a Maven Project

In Maven, you can manage dependencies using a pom.xml file. Here’s how you can add dependencies to your pom.xml file: That’s it! Your Maven project now has the necessary dependencies to build and run successfully. When you build a Java project with Maven, by default it creates a packaged output called a JAR (Java ARchive)… read more »