Category: Java
How to Write text to File in Java
This tutorial show you how to write text to File using java. We can write text to a file in a couple of ways. First we explore the old way using a BufferedWriter. Next...
How to Create a File in Java
This tutorial shows you how to create a file using java. First we explore the old way using the File class. Next we explore the new Path class introduced in Java 7. Create a...
Generic Rest Service Jersey Error Handling
This tutorial explains the best practices how to handle jersey error handling. Basically we create a generic exception handler that will handle all exceptions thrown by any methods inside a rest service. Dependencies Add...
Creating and running a thread in Java
In this example, we will create and running a thread in a java application. This example is very basic but it helps to understand how a thread can be created and executed. We can...
List all System Properties in Java
This example show how you can list all system properties of a running java application. You can use this as a reference to look up which properties are by default available. Print System Properties...
Get Uptime Operating System Windows, Mac, Linux
This example shows you how you can get the uptime for different operating systems like Windows, Mac or Linux. In windows, you can execute the net stats srv command. In Unix, you can execute...
How to get Uptime Java JVM running Application
This tutorial shows you how to get the uptime (in milliseconds) of your running JVM/java application. This could be used to display in a fancy dashboard for your users or administrators. We can obtain...
Context and Dependency Injection @Disposes and @Produces
In this example we will use Context and Dependency injection annotations @Produces and @Disposes. We can create an injectable java.sql.Connection using the @Produces annotation. Remember that the container manages the initialisation and destruction of...
Java SE: Unit Testing CDI with JUnit and JBoss Weld SE
In this tutorial we will show you how to use Java EE Context Dependency Injection in a Java SE environment by Unit Testing CDI with JUnit and JBoss Weld. To enable CDI in our...