Sometimes a program or an application stops responding or you are working on a terminal and want to stop a process. In such cases you need to terminate or kill that process. Linux provides a kill command that takes the PID or Process Id of the process and terminates it. In most cases, the only way to identify the process to be stopped or getting its PID is by using the specific port on which it is running or listening. Thus, first you must be able to find the process listening on a specific port and then kill it. This post will outline different commandsRead More →

Often we need to find out a process or a service running on some port. This is because we have to start a new instance of the same or different service on that port but we cannot until the current process is terminated. Thus, it is required to find out the PID of a process using its port so that the process can be terminated. There are many different ways in which a process can be checked using its port and this article will discuss them in detail with example. Method 1: Using lsof command lsof stands for List of open files and can beRead More →

A javascript object is a collection of properties in key-value pairs. An empty object means an object which does not contain any property. To know about javascript objects, refer this post. Before accessing a property of an object, it is recommended to check for object being empty to avoid run time errors. There are many methods to test empty object in javascript and this post will discuss them with examples. Method 1: Iterating over object properties Iterate over the properties of object which needs to be checked for being empty using a for loop. In every iteration, check if the property belongs to this objectRead More →

If some property with a given key is accessed in the object and it is not present, then an error is raised. Thus before accessing the property, it is recommended to check if a property with that key is present in the object so that if it is not present, then there is no error and an alternate action can be taken. This post will discuss different methods in which it can be checked if a key exists in an object. Method 1: Using in operator in operator checks for the presence of a property with the given key in an object and returns trueRead More →

Why java version at runtime Sometimes you need to execute some code conditionally based on the current executing java version. For example, there is some functionality whose code was different on an earlier java release but on later releases it was optimized as per the new features introduced in java itself. This requires that you determine the version of java during program execution and execute code according to it. This post will list down different ways in which this is possible Using java.version system property Java provides a property java.version which returns the version of java runtime, that is, the environment in which the currentRead More →

Determining the size of a directory or its sub-directories is often required for the purpose of monitoring such as a folder which is taking space above some limit. du command in linux Linux provides du(stands for disk usage) command to list down the size of a folder and its sub-folders and files contained in them. By using this command, you can determine disk usage by folders list folders by their size retrieve the size of directory, subdirectories and even the files contained in them. du command has many options to generate different types of output such as list down the size of folders in blocks,Read More →

Every server runs at some pre-defined default ports. But you can also change the default setting so that the server listens at the configured port number. Default ports of Wildfly Following are the default ports of wildfly for http and https protocols. http: 8080 https: 8443 How to change ports in wildfly There are two methods to change default ports in wildfly 1. From configuration XML Navigate to the wildfly install location or where it was extracted and look for standalone.xml inside <wildfly location>/standalone folder. This is the configuration file for wildfly. Edit the file and search for socket-binding-group tag. It would normally be located atRead More →

Almost every java developer would have encountered the below error sometime or the other while executing a java program. Exception in thread “main” java.lang.UnsupportedClassVersionError: com/codippa/HelloWorld has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0 java.lang.UnsupportedClassVersionError means that the version of JDK on which the java file was compiled was a higher version and the JRE version on which it is being executed is of a lower version. Example, a file compiled on JDK 8 is being executed on JRE 6. And that is alsoRead More →

You can easily determine the jdk version with which a given java file was compiled using the below command. javap –verbose <class file name> The above command should be executed at the location where the class file is placed or otherwise the entire path of class file needs to be given. Open the command prompt on windows or terminal on linux/mac systems and navigate to the location of class file and execute the above command. Example, E:\com\codippa>javap -verbose HelloWorld.class Note the folders com/codippa is the package of this class since a java file when compiled is located inside the folders that match its package. ThisRead More →