Monday, October 2, 2017

JAVA application Monitoring using JMX

Your application can be started with following JMX parameter.


You can set System property as JMX port as follows to enable JMX monitoring.

System.setProperty("", 12345);

Then, use VisualVM to monitor your application. You can monitor CPU, Memory, Threads etc using this VisualVM tool.

For more information visit :-

Tuesday, August 29, 2017

Find files in Linux and move files

Following command can be used to find files in a directory and move found files into /home/sujith/files/ location.

find . -name "*" -maxdepth 1 -exec mv -t /home/sujith/files {} +

Monday, August 28, 2017

Copy large number of files between Linux servers

You can use "rsync" command to sync data between two locations.

rsync -r dir1/ dir2
sync the contents of dir1 to dir2 on the same system (-r option for recursive)

rsync -a dir1 username@remote_host:destination_directory
sync directory from the local system to a remote system ( pushing files to destination)

rsync -a username@remote_host:/home/dir1 place_to_sync_on_local_machine
sync a remote directory to the local system (pulling files from remote machine)

Also, you can compressed and sync files between locations using following command.

rsync -az source destination

Thursday, August 24, 2017

Linux shell script to find files and copy into another location

You can use following shell script to find files in directories and copy into another location.

for k in `cat errlog_tmp.txt`; 
arr=( $(find . -name "$k*" -type f));
echo $arr;( cp $arr "./error1$k"); 

Above shell will cat file names in "errlog.txt" and find in the current directories. After successful file found, it is copied into "./error/" directory.

Tuesday, July 18, 2017

JAVA Web Start (JWS) JNLP Example

JWS is introduced to use client side application processing through web. Clients are downloading JNLP application and execute the application to process data.

  1. Create JAR file that you want to execute it in client side (TestJNLP.jar)
  2. Sign the file using your certificate
    1. keytool -genkey -keystore testKeys -alias test
    2. jarsigner -keystore testKeys TestJnlp.jar test
  3. Create JNLP file (Test.jnlp)
  4. Deploy JNLP file and signed JAR file in web server
  5. Download JNLP file and execute application (http://localhost:8080/Test.jnlp)

Sample JNLP file

<?xml version="1.0" encoding="utf-8"?><jnlp spec="1.0+" codebase="http://localhost:8080/" href="Test.jnlp">
<title>Jnlp Testing</title>
<homepage href="http://localhost:8080/" />
<description>Testing Testing</description>
<j2se version="1.6+" />
<jar href="TestJnlp.jar" />
<application-desc main-class="com.test.TestJnlp" />

For Windows OS, change OS type in resource XML tag as follows.

<resources os="Windows">

For native library access, you have to create DLL into JAR file and then signed the JAR file using certificate and deploy into web server. Then, you have to change JNLP file as follows.

<resources  os="Windows">       
          <j2se  version="1.6+" />    
          <jar  href="TestJnlp.jar" />
           <nativelib  href="DLLtoJAR.jar" />

Create DLL into a JAR file using single command

jar cvf DLLtoJAR.jar testDLL.dll


Tuesday, May 9, 2017

MAVEN build plugins

Following plugins can be used to build jar file with sources embedded.

<!-- adding your sources into jar file -->


<!-- copying your resource folder into build directory -->
<!-- here the phase you need -->

<!-- copying your library folder into build directory -->

<!-- setting your main runner class -->

Wednesday, March 1, 2017

Object to JSON string mapper in JAVA

Following code can be used to convert JAVA objects to JSON string. You have to use jackson JAVA library for objects to JSON conversion.

RequestMessage requestMessage = new RequestMessage();
        RequestEntity requestEntity = new RequestEntity();

ObjectMapper mapper = new ObjectMapper();

Converted JSONstring will like this.


Monday, February 13, 2017

Install local jars in maven repository

Following command can be used to install local or internal jar files in maven repository.

mvn install:install-file -Dfile=d:/libs/test.jar -DartifactId=test -Dversion=1.0 -Dpackaging=jar

After installing jar files in maven repository, you can use the jar files in maven project as a dependency in pom.xml.


Sunday, February 5, 2017

JBoss EAP6.4 log4j deadlock error

JBoss6.4 is using log4j 'per deployment logging' function. That means, JBoss application server itself adding log4j into application. When using multiple log4j implementations, log4j deadlock scenario may be caused. To avoid that, it can be added 'jboss-deployment-structure.xml' file into JBoss application WEB-INF.

Error message
"http-/" #109 daemon prio=5 os_prio=0 tid=0x00007fa3e4163000 nid=0x636a waiting for monitor entry [0x00007fa3ae4e7000]
     java.lang.Thread.State: BLOCKED (on object monitor)

<!-- exclude the logging subsystem to disable deployment unit processors from running -->
<subsystem name="logging" />

Tuesday, January 3, 2017

Cross domain security error dwr

You can avoid security checking in client side in dwr by adding following code into web.xml file