How to add an Element to an Array type using MongoDB Java Driver ?

Pushing an element into an array type in MongoDB collection using Java Driver is not so obvious at the first attempt. I would share a sample program today that create a MongoDB connection and insert an element into an array type within a collection. We are going to connect to a MongoD server installed in […]
Continue reading…

 

How to find all live threads in JVM?

Java JMX API provides you some useful classes to find out details about your JVM. One of those classes is ManagementFactory, This class provides API to find meta data about the JVM. In the below given example we will find all the live threads in the JVM and its state.

Console output.

Continue reading…

 

How to find the compiler version from a class file?

There is a tool called javap to find out the compiler version and much more from a class file. See the below given console output to get more details. javap is located in %JAVA_HOME%/bin.

Continue reading…

 

How to create and start threads in java?

Unlike many other languages it is simple to create and manage threads in java. Your class can gain the concurrent behavior through either extending java.lang.Thread class or implementing java.lang.Runnable interface. Thread class itself implements Runnable interface, due to the same reason compiler will not force the programmer to give an implementation of run() method if […]
Continue reading…