Category: Java

Manage Multiple JDKs in Linux: Default & Switch Guide

In the dynamic world of Java development, you often need to manage multiple JDKs in Linux simultaneously. Indeed, this is crucial for: Ensuring Compatibility: Testing your applications across different JDK versions. Supporting Legacy Projects: Maintaining projects that rely on specific, older JDKs. Facilitating Multi-Project Development: Handling projects with diverse JDK requirements. Therefore, this guide will …

Continue reading

Streamlining Java Apps: Effortless Service Management with systemd in Ubuntu

Tired of wrestling with manual start/stop commands for your Java apps as systemd services in Ubuntu? In today’s streamlined Ubuntu environments, systemd stands as the quintessential service manager. Therefore, let’s delve into the process of running your Java apps as systemd services in Ubuntu, simplifying management and ensuring robust automatic restarts. Imagine the all-too-familiar scenario: …

Continue reading

Streamline Your Java App: Running it as a Service with Upstart in Ubuntu

Want to simplify managing your Java application as a service with Upstart in Ubuntu? Hi, one day, while I was deep into my Java project, I found myself in a repetitive cycle of debugging. Specifically, I’d tweak configuration files, restart the application, and then repeat the process. To stop my Java application, I’d hunt down …

Continue reading

Replication aware JDBC connection in java and MySQL

Hi, recently I was reviewing the code a project which was having some database issues, while the review I found that the project environment was setup with the MySQL with one master node and two slave node, and I was surprised that in the code they have used the default JDBC driver for database connectivity which …

Continue reading

How to enable garbage collection logging (GC logs) in Apache tomcat

In this article I’ll provide information about how to enable garbage collection logging (GC logs) in Apache tomcat. GC logs are very important when you are debugging an application. GC logs helps to analyse how your program uses the memory. GC logs also helps to find how often garbage collector cleans the memory for unused objects. …

Continue reading

Send error logs through email using log4j SMTP appender

recently I was reading about Apache log4j appenders. and found log4j SMTPAppender which sends an e-mail when a specific logging event occurs, typically on errors or fatal errors. That time I got idea to write this post to send error logs through email using log4j SMTP appender. for a developer error logs are very important. and …

Continue reading

Download/Attach source-code/java-docs with maven dependencies

I am using Maven in my projects from last couple of years, and the automatically downloading the Jars from repository feature of maven is really helpful for developers. But If you are using Eclipse and want to read/analyse Source Code or Java Doc of API then you need the jar file that contains the Source …

Continue reading

Accessing Private Members of a Java class using Reflection

Somebody asked me that, “Is there any way of accessing private members of a Java Class?” Then I got the idea to write this article, because Java Reflection API provides a feature for accessing private members of a Java Class. java.lang.reflect package provides the AccessibleObject class that is parent class of Constructor, Method, and Field …

Continue reading

Introduction to Nonblocking Sockets

Here, I am going to explain what non-blocking sockets are, how it works, and where it can be useful, everything in details. Preface: Non-blocking sockets are introduced in Java 2 Standard Edition 1.4. It allows network communication between applications without blocking processes using the sockets. A nonblocking socket allows input/output operation on a channel without …

Continue reading