Home » Core Java » lang » Page 4

lang

Check when an object will be reclaimed

This is an example of how to check when an object will be reclaimed. Checking when an object will be reclaimed implies that you should: Create a new Object. Create a new ReferenceQueue, to which registered reference objects are appended by the garbage collector after the appropriate reachability changes are detected. Create a new PhantomReference that refers to the given ...

Read More »

Check when an object is no longer referenced

In this example we shall show you how to check when an object is no longer referenced. To check when an object is no longer referenced one should perform the following steps: Create a new Object. Create a new ReferenceQueue, to which registered reference objects are appended by the garbage collector after the appropriate reachability changes are detected. Create a ...

Read More »

Get JVM Start Time-Date

With this example we are going to demonstrate how to get the JVM Start Time-Date. We are using the RuntimeMXBean, that is the management interface for the runtime system of the Java virtual machine. In short, to get the JVM Start Time-Date you should: Get the JVM’s thread system bean, that is the RuntimeMXBean, using the getRuntimeMXBean() API method of ...

Read More »

Obtain System Properties

This is an example of how to obtain the System Properties. We are using the RuntimeMXBean, that is the management interface for the runtime system of the Java virtual machine. Getting the System Properties implies that you should: Get the JVM’s thread system bean, that is the RuntimeMXBean, using the getRuntimeMXBean() API method of ManagementFactory. Get the Map of the ...

Read More »

Get Class Path

In this example we shall show you how to get the Class Path. We are using the RuntimeMXBean, that is the management interface for the runtime system of the Java virtual machine. To get the Class Path with the the RuntimeMXBean one should perform the following steps: Get the JVM’s thread system bean, that is the RuntimeMXBean, using the getRuntimeMXBean() ...

Read More »

Number of current threads

With this example we are going to demonstrate how to get the number of current threads in a JVM. We are using the ThreadMXBean that is the management interface for the thread system of the Java virtual machine. In short, to get the number of current threads you should: Get the managed bean for the thread system of the Java ...

Read More »

Get JVM up time

This is an example of how to get the JVM up time. We are using the We are using the RuntimeMXBean, that is the management interface for the runtime system of the Java virtual machine. Getting the JVM up time implies that you should: Get the JVM’s thread system bean, that is the RuntimeMXBean, using the getRuntimeMXBean() API method of ...

Read More »

Get System Time Example

In this example we shall show you how to get the System Time. We are using the System class, that contains several useful class fields and methods. It cannot be instantiated.To get the System Time one should perform the following steps: Use the currentTimeMillis() API method of System. Thi method returns the current time in milliseconds. Note that while the ...

Read More »

Get classpath Example

With this example we are going to demonstrate how to get the classpath. We are using the System class, that contains several useful class fields and methods. This class cannot be instantiated. In short, to get the classpath using System class you should: Use the getProperty(String key), for the java.class.path key. This method gets the system property indicated by the ...

Read More »

Get system properties with System

With this example we are going to demonstrate how to get system properties. We are using the System class, that contains several useful class fields and methods. In short, to get system properties with System class you should: Call getProperties() API method of System. This method determines the current system properties. It returns an object of the Properties class, that ...

Read More »