Techies Experience

Thursday, March 20, 2014

JDK-32-bit JVM-vs-64-bit JVm

Technology Update : What is diffrence between 32 bit JVM and 64 bit JVM.

What is diffrence between JDK 32 bit- & JDK 64 bit JVM ?


We have used jdk many times for java development but we facing one question every time
what is diffence between 32 bit jvm and 64 bit jvm?.

What is 64 bit JVM & 32 bit JVM ?


64 bit JVM runs in the 64-bit environment of a 64-bit OS on a 64-bit processor. The major differences between 32-bit and 64-bit jvm are the sizes of machine words,
the amount of addressable memory, and the Operating System memory in use.
The main advantage of Java in a 64-bit environment is the larger address space.
This allows for a much larger Java heap size and an increased maximum number of Java Threads,which required for large applications.
many user assume that we are using 32 bit to 64 bit environment means ,
we are doubled the size of Java Integers from 32 bit to 64 bit. we are not doing any modifications in JVM releated specifications.

When to use 32 bit and 64 bit JVM ?


If Java Application running on a system is required more RAM greater than 4GB then will use 64 bit
other caes 32 bit is fine.

How to check JVM is 32 bit or 64 bit


1.Using Java Version

Case 32 bit it will print
 java version "1.6.0_24"  
 OpenJDK Runtime Environment (IcedTea6 1.11.1) (rhel-1.45.1.11.1.el6-i386)  
 OpenJDK Server VM (build 20.0-b12, mixed mode)  

Case 64 bit it will print
 java -version  
 java version "1.6.0_24"  
 Java(TM) SE Runtime Environment (build 1.6.0_25-b06)  
 Java HotSpot(TM) 64-Bit Server VM (build 20.0-b11, mixed mode)  

2.Using System property sun.arch.data.model

one more option to find find whether JVM is 32 bit or 64 bit by using System.getProperty("sun.arch.data.model") at least on Sun's hotspot JVM. for 32 bit JVM "sun.arch.data.model" will be 32 and for 64 bit JVM this would be 64.
 System.out.println("32 /64 JVM Bit size: " + System.getProperty("sun.arch.data.model"));  
 Output:  
 JVM Bit size: 32 //JVM is 32 bit  
 JVM Bit size: amd64 //JVM is 64 bit  
3.Using System.getProperty("os.arch")

"os.arch" is another System property which you can use to find whether installed JRE or JVM is 32 bit or 64 bit. by name it sounds that it will return operating system arch but you can still give it a try. Though I haven't tested on all different JVM, I have read that it can indeed return JVM Bitness.If you try this on 64 bit machine and 32 bit JVM combination than please let us know what does it return. here is what it returns in case of 32 bit JVM:
 System.out.println("JVM Bit size: " + System.getProperty("os.arch"));  
 output :  
 JVM Bit size: x86 //on 32 bit JVM  
 JVM Bit size: amd64 //on 64 bit JVM  

5.Using java -d64 -version

using this command will get the below mentioned output.
 java -d64 -version   
 This Java instance does not support a 64-bit JVM.  
 Please install the desired version.  
That's all the ways we can used to check JVM is 32 bit or 64 bit. any improvements , suggestions are highly appreciated.
some references also you can check online here.

References :
  1. Check JDK 32 bit or 64 bit @ http://www.java.com/en/download/faq/java_win64bit.xml
  2. Lotus Media Centre @ http://lotusmediacentre.com/difference-between-32-bit-and-64-bit-jvm-choose-wisely/

Wednesday, March 12, 2014

How to use Jboss Tattletale

Jboss Tattletale :generates reports that will show dependencies and general information and duplication of jar files

JBoss Tattletale Introduction


Jboss Tattletale is tool will help you to understand your project structure, dependencies available in your project.


Below mentioned list of activities we can do with the help of Jboss Tattletale :

  1. Find dependencies between JAR files
  2. Find missing classes from the classpath
  3. Check for duplicated multiple JAR files
  4. Verify the SerialVersionUID of a class
  5. Jar file details with version numbers
  6. Unused JAR files/ sealed / signed JAR archives
  7. Locate a class in a JAR file
  8. Get the OSGi status of your project

JBoss Tattletale will recursive scan the directory pass as the argument for JAR files and then build the reports as HTML files.

How to use Jboss Tattletale in your project.


Prerequisites to install jboss tattletale is JDK 1.5 or higher version is required.

How to install jboss tattletale


you can download jboss tattletale from site http://www.jboss.org/tattletale/downloads once donwload is complete
you can extract the same using command

 unzip jboss-tattletale-1.1.1.GA.zip  
or

 tar xzf jboss-tattletale-1.1.1.GA.tar.gz  

How to Configure tattletale


you can do the tattletale configuration in this file. this file is located under main directory.

Tattletale command to generate analysis Report

 java -Xmx512m -jar tattletale.jar [-exclude=<excludes>] <scan-directory> [output-directory]
command used for generating below Report.
 java -Xmx512m -jar tattletale.jar /home/ISG/deepak641/Desktop/DESKTOP/MyServers/jboss-5.1.0.GA/  
You will get output like this in HTML format.

JBoss Tattletale 1.1.2.Final


Dependencies


Reports

Archives


Generated by: JBoss Tattletale 1.1.2.Final check each and every link manually you will get respective detail report.

References :

  1. Check Jboss Tattletale Guide @ http://www.jboss.org/tattletale
  2. SVN Repository @ http://anonsvn.jboss.org/repos/tattletale

Tuesday, March 11, 2014

How to Integrate Struts 1.x with Struts 2.x.

How to Integrate Struts 1.x with Struts 2.x Before diving into the integration of Struts framework,
let us first take a look at the Struts 1.x and 2.x configuration separately. suppose we have an exisisting web Application and we need to integrate struts 1.x application to struts 2.x .

Struts 1.x web.xml file


 <?xml version="1.0" encoding="ISO-8859-1"?>  
 <!DOCTYPE web-app  
  PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"  
  "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">  
 <web-app>  
  <!-- Standard Action Servlet Configuration (with debugging) -->  
  <servlet>  
   <servlet-name>action</servlet-name>  
   <servlet-class>  
       org.apache.struts.action.ActionServlet  
      </servlet-class>  
   <init-param>  
    <param-name>application</param-name>  
    <param-value>ApplicationResources</param-value>  
   </init-param>  
   <init-param>  
    <param-name>config</param-name>  
    <param-value>/WEB-INF/struts-config.xml</param-value>  
   </init-param>  
   <init-param>  
    <param-name>debug</param-name>  
    <param-value>2</param-value>  
   </init-param>  
   <init-param>  
    <param-name>detail</param-name>  
    <param-value>2</param-value>  
   </init-param>  
   <init-param>  
    <param-name>validate</param-name>  
    <param-value>true</param-value>  
   </init-param>  
   <load-on-startup>2</load-on-startup>  
  </servlet>  
  <!-- Standard Action Servlet Mapping -->  
  <servlet-mapping>  
   <servlet-name>action</servlet-name>  
   <url-pattern>*.do</url-pattern>  
  </servlet-mapping>  
  <!-- Struts Tag Library Descriptors -->  
  <taglib>  
   <taglib-uri>/WEB-INF/struts-bean.tld</taglib-uri>  
   <taglib-location>/WEB-INF/struts-bean.tld</taglib-location>  
  </taglib>  
  <taglib>  
   <taglib-uri>/WEB-INF/struts-html.tld</taglib-uri>  
   <taglib-location>/WEB-INF/struts-html.tld</taglib-location>  
  </taglib>  
  <taglib>  
   <taglib-uri>/WEB-INF/struts-logic.tld</taglib-uri>  
   <taglib-location>/WEB-INF/struts-logic.tld</taglib-location>  
  </taglib>  
 </web-app>  



Struts 2.x web.xml file


 <!DOCTYPE web-app PUBLIC  
  "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"  
  "http://java.sun.com/dtd/web-app_2_3.dtd" >  
    
 <web-app>  
      <display-name>Struts 2 Web Application</display-name>  
    
      <filter>  
           <filter-name>struts2</filter-name>  
           <filter-class>  
         org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter  
         </filter-class>  
      </filter>  
    
      <filter-mapping>  
           <filter-name>struts2</filter-name>  
           <url-pattern>/*</url-pattern>  
      </filter-mapping>  
    
 </web-app>  

web.xml after Integration
  <!DOCTYPE web-app PUBLIC   
  "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"   
  "http://java.sun.com/dtd/web-app_2_3.dtd" >   
     
  <web-app>   
    <display-name>Struts 2 Web Application</display-name>   
      <!-- mapping for struts 2.x -->    
    <filter>   
       <filter-name>struts2</filter-name>   
       <filter-class>   
      org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter   
      </filter-class>   
    </filter>   
     
    <filter-mapping>   
       <filter-name>struts2</filter-name>   
       <url-pattern>/*</url-pattern>   
    </filter-mapping>   
      <!-- mapping for struts 1.x -->  
            <servlet>  
           <servlet-name>action</servlet-name>  
           <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>  
           <init-param>  
                <param-name>config</param-name>  
                <param-value>/WEB-INF/struts-config.xml</param-value>  
           </init-param>  
           <init-param>  
                <param-name>debug</param-name>  
                <param-value>3</param-value>  
           </init-param>  
          <init-param>  
                <param-name>detail</param-name>  
                <param-value>3</param-value>  
           </init-param>  
           <load-on-startup>0</load-on-startup>  
           </servlet>  
           <servlet-mapping>  
                <servlet-name>action</servlet-name>  
                <url-pattern>*.do</url-pattern>  
           </servlet-mapping>  
             
 <servlet>  
     
  </web-app>   
do let me know your comment.

Tuesday, March 4, 2014

Free Maker template error in Struts 2

While doing struts 2 project deployments we are facing one major issue related to free marker template.

Free Marker Error in Struts 2

Quick solution to fix this issue is either upgrade the jar files struts2-core-2.0.6 and xwork-2.0.1 to higher version or else we need to add below mentioned tag in respective jsp page.
add below mentioned tag in header section of that page.

 <sx:head debug="false" parsecontent="true">  

Jboss 4 to Jboss 5 migration Steps

Jboss 4 to Jboss 5 migration steps

Jboss Application server version 4.x to Jboss Application server version 5.x migration steps


This document is guide for upgrading JBoss Application Server version 4.x to JBoss Application Server 5.x.
I'm sharing here my experience while doing migration from jboss 4 to jboss 5.

Below mentioned Steps we are implemented while doing migration from jboss 4 to jboss 5.

  1. Check Jboss Structure.
  2. Create checklist of jar files.
  3. Keep only application specific jar files in your application.
  4. Check version of jar files like servlet.jar.
  5. Jar file details with version numbers.
  6. Remove Unwanted JAR Files which are conflicting with jboss 5.
  7. Move common files under JBOSS_HOME/common/lib

References :

  1. Jboss Community Upgrade Guide - JBoss 4 to 5 @ https://community.jboss.org/message/757106
  2. D-Zone @ http://java.dzone.com/articles/migrating-jboss-4-jboss-5
  3. Migrating-your-application-jboss-4x-jboss-5x @ migrating-your-application-jboss-4x-jboss-5x