SupportWriter space ↗
REFERENCE LIBRARY

References from other publishers

Republished articles with source attribution. This collection is separate from Diary Coding’s original guides and does not display ads.

Read original guides → · Editorial policy

FOR YOUR CURIOSITY

Latest notes.

JSCH / NOTES</>↗
JSch26 Apr 2025

How do I handle session and channel cleanup in JSch?

When using JSch (Java Secure Channel) to establish SSH connections in your Java application, it’s essential to properly manage resources like Session and Channel objects to prevent resource leaks. Cleanup involves explicitly closing all channels and disconnecting the session once the work is complete. Here is how you can handle session and channel cleanup in […]

Wayan · 4 min read
UTIL PACKAGE / NOTES</>↗
Util Package26 Apr 2025

How do I conditionally execute code with Optional’s ifPresent and ifPresentOrElse?

In Java, the Optional class provides methods for handling values that may or may not be present. The methods ifPresent and ifPresentOrElse are particularly useful for executing code conditionally based on whether a value is present in the Optional. 1. Using ifPresent The ifPresent method executes a Consumer when the value is present (i.e., it’s […]

Wayan · 3 min read
UTIL PACKAGE / NOTES</>↗
Util Package26 Apr 2025

How do I throw exceptions if Optional is empty using orElseThrow?

In Java, you can throw exceptions when an Optional is empty using the orElseThrow method. This method accepts a Supplier that provides the exception to be thrown if the Optional is empty. Here’s the syntax and an example: package org.kodejava.util; import java.util.Optional; public class Main { public static void main(String[] args) { Optional<String> optionalValue = […]

Wayan · 2 min read
JSCH / NOTES</>↗
JSch25 Apr 2025

How do I run a simple command over SSH with JSch?

To execute a simple command over SSH using JSch (Java Secure Channel), you can use the ChannelExec channel provided by the JSch library. Here’s how you can achieve that: Maven Dependency: If you’re using Maven, include the JSch library in your pom.xml file: <dependency> <groupId>com.jcraft</groupId> <artifactId>jsch</artifactId> <version>0.1.55</version> <!– Use the latest version –> </dependency> Code […]

Wayan · 3 min read
SERVLET / NOTES</>↗
Servlet25 Apr 2025

How do I use listeners like ServletContextListener for lifecycle management?

In Jakarta EE (formerly Java EE), you can use listeners like ServletContextListener to manage the lifecycle of a web application’s ServletContext. It provides hooks to execute logic during the initialization and destruction stages of the application. This can be useful for resource initialization, cleanup, or logging purposes. Here’s how you can use ServletContextListener: 1. Implementing […]

Wayan · 4 min read
SERVLET / NOTES</>↗
Servlet25 Apr 2025

How do I handle exceptions and errors in Jakarta Servlets?

Handling exceptions and errors in Jakarta Servlets involves several approaches, ranging from defining error-handling configurations in the deployment descriptor (web.xml) to using annotations and specific coding practices. Below are the typical ways to handle errors and exceptions in Jakarta Servlets: 1. Using web.xml for Declarative Exception Handling In the web.xml file, you can define error […]

Wayan · 6 min read
✳

Knowledge grows when shared.

Stay curious. There is always something new to learn.

Explore notes ↗
Putu Adi Guna Permana
ABOUT THE AUTHOR

Dr (C). Ir. Putu Adi Guna Permana, S.Kom., M.Kom., IPM., ASEAN Eng.

Writer and founder of Diary Coding — sharing notes, tutorials, and experiences about programming for anyone who wants to keep learning.