JAVA
Finding selected checkbox items in a JSF dataTable
This is one of those problems that I couldn’t find a complete example for when I needed it, so hopefully this will save somebody else the extra time it took me to piece it together.We frequently need to have data tables in our UI, and allow the user to select a subset of those items for action. In JavaServer Faces, this means having a DataTable, each row having its own checkbox. But when the action is triggered, how to we find which items the user has selected.The first step is to add a boolean property to your objects that can represent the selection. If you have a lot objects in your ...
14,719 1 EXAMPLE JAVASERVER FACES JSF DATATABLE CHECKBOX
Singleton Design Pattern in Java
Singleton is frequently used in applications where resource may be expensive to create and no instance specific state needs to be maintained. For example, when creating database connection, a singleton may be needed. Today we will share the famous Singleton design pattern in Java.1. DefinitionSingleton design pattern is a design pattern that restricts the instantiation of a class to one object. It is one of the most well-known design patterns.2. ApplicationSingleton can be used in many occasions, for example, one database can have only one connection or connection coun...
14,702 2 JAVA DESIGN PATTERN SINGLETON MULTITHREAD
Top 10 essential Java classes
When we write Java programs, we will frequently use some classes such as java.lang.String. There are some essential Java classes which we may use frequently, there is no strict rules for the selection of essential Java classes, in fact there are no rules followed. It depends on what projects you are doing or what you have done,, so every one may have his own choices about the top essential Java classes in his mind. Here we list the top 10 essential Java classes you may agree with.1. java.lang.String2. java.lang.System3. java.lang.Exception4. java.util.ArrayList5. java.util.HashMap6. java.lang....
14,610 1 JAVA CLASS ESSENTIAL CLASS TOP 10
Use Memory Analyzer Tool in Eclipse
When developing applications, we often encounter memory issues of an application. To analyze how much memory each class takes, we need to have some specific tools to assist us. One of them is Memory Analyzer Tool on Eclipse.The Eclipse Memory Analyzer is a fast and feature-rich Java heap analyzer that helps you find memory leaks and reduce memory consumption.To use the Memory Analyzer Tool, you first need to install it on Eclipse. You can go to Help -> Install New Software.... Paste http://download.eclipse.org/mat/1.4/update-site/ in Work with field and press Enter. Then follow the st...
13,085 1 MEMORY ANALYZER TOOL ECLIPSE HEAP DUMP HPROF
MaxHeapSize in JVM
MaxHeapSize is an option which is to set the JVM maximum heap size can be allocated. We can specify the MaxHeapSize as VM argument when we run the program by setting -XX:MaxHeapSize=, here can be 2M, 20M, 200M etc.We can also view the current MaxHeapSize set by setting different JVM options. To view the MaxHeapSize, we can use two JVM options : -XX:+PrintFlagsFinal and -XX:+PrintCommandLineFlags. Below is one example when running -XX:+PrintFlagsFinal: bool MaxFDLimit = true {product}uintx MaxGCMinorPauseMillis = 4294967295 {pro...
13,082 0 JVM MAXHEAPSIZE ALIGNMENT
Different types of keystore in Java -- DKS
Domain KeyStore(DKS) is a keystore of keystore. It abstracts a collection of keystores that are presented as a single logical keystore. Itself is actually not a keystore. This new keystore type is introduced in Java 8. There is a new class DomainLoadStoreParameter which closely relates to DKS.To load different keystores into the single logical keystore, some configuration is needed. Here is the format of the configuration for grouping different keystores.domain [ ...] { keystore [ ...] ; ...};Below is one sample configuration for domain domain.domain app1 { keystore app1-...
Recursive class initialization in Java
When a Java class is referenced and initialized, it has to go through the loading and linking first. Once the loading and linking complete successfully. The class will be initialized. The static variables and constant variables will be initialized during this process. Once the class is initialized, it is ready for use.If when class A is initialized and it is referencing a class B, the class B will also get initialized. But what will happen if class B is referencing class A as well? This is called recursive class initialization. Will there be a deadlock if this case happens? No, JVM will take c...
12,782 0 JAVA JVM CLASS INITIALIZATION STATIC FINAL
Java AbstractMethodError explained and demonstrated
According to Oracle Java API documentation, AbstractMethodError is a kind of runtime error where the application is having some incompatible changes which leads to a missing implementation of an abstract method. Below is the official description.Thrown when an application tries to call an abstract method. Normally, this error is caught by the compiler; this error can only occur at run time if the definition of some class has incompatibly changed since the currently executing method was last compiled.Well this can happen in cases where there are inconsistent library upgrade. For example, if a l...
12,508 0 JAVA ABSTRACTMETHODERROR