A Developer's Diary

Apr 4, 2008

Java - Debugging In Tomcat 5.5

Steps to be followed to enable debugging in Tomcat 5.5 through Eclipse

Configuring Tomcat
1. Go to configure options in Tomcat5.5
2. Select Tab "Java" and in Java Options add the following lines
-Xdebug
-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000

Configuring Eclipse
1. Click on Debug
2. Select Remote Java Application
3. In connection properties add host and Port = 8000
4. Add break point

Happy Debugging :)
Read more ...

Apr 3, 2008

Shell Scripting - Parallel Process Execution in Background

Command for checking the background jobs which are in running state

jobs -r | wc -l


Non-interactive ftp transfer to automate uploading of files parallely on different platforms.

#!/bin/bash

LINUX=linux
AIX=aix
SUNOS=sunos

WIN32=win

MACHINES=" \
    $LINUX \
    $AIX \

    $SUNOS \
    $WIN32"

function checkjobs(){
if [ `jobs -r | wc -l` -eq 0 ]; then

echo "All Background Process completed Successfully"
return 0
fi
sleep 10

checkjobs
}

function upload(){

if [ $# -eq 0 ]; then

echo "Missing Argument"
exit 1
fi

# Non-interactive ftp transfer
ftp -i -v -n hostname <<END_FTP

    user root root
    binary
    cd test
    put "file$1.exe"
    bye

END_FTP
echo "Uploaded file$1.exe"
return 0
}

function uploadfile(){
echo "Uploading Files  Started"
for host in $MACHINES

do
echo "Uploading FILES on host $host"
upload $host &
done

}

uploadfile
checkjobs
echo "All Files Uploaded Successfully"





Making things more simpler, we can use the special command wait and rewrite uploadfile so that we need not check for the background processes

function uploadfile(){
echo "Uploading Files  Started"

for host in $MACHINES
do
echo "Uploading FILES on host $host"

upload $host &
done
wait
}

uploadfile
echo "All Files Uploaded Successfully"





Read more ...

Mar 31, 2008

Shell Scripting - Rotating Progress Bar

The echo -e command is used to change the term color


echo -e "\E[40;32m\b\c"
#Changes the term color to green with black background



#!/bin/bash

function success_banner()

{
echo -e "\E[40;32m\b\c"
echo -e "[OK]"
echo -e "\E[40;37m"

}

function progress_banner()
{
echo ""
echo "##############################################################"

echo ""
echo -e "Step: $1 \b\c"
}

function rotate_line(){

INTERVAL=1
timecount="0"
while :
do
timecount=`expr $timecount + 1`

case $timecount in
"1")
echo -e "-\b\c"

sleep $INTERVAL
;;
"2")
echo -e '\\'"\b\c"

sleep $INTERVAL
;;
"3")
echo -e "|\b\c"

sleep $INTERVAL
;;
"4")
echo -e "/\b\c"

sleep $INTERVAL
;;
*)
timecount="0" # Reset the count to 0

esac
done
}

function start_rotation(){
rotate_line &

}

function stop_rotation(){
rotate_line_pid=$!
kill -9 $rotate_line_pid

echo -e "\b\b\b"
}

progress_banner Rotation_Bar_Started
start_rotation
sleep 5
stop_rotation
success_banner Ok




Read more ...

Mar 26, 2008

Finding Linux Version

Linux Release Version can be obtained by executing


cat /etc/redhat-release


For getting linux kernel versions execute

uname -a or uname -r

Read more ...

Mar 2, 2008

Accessing 32 bit DLLs' from 64 bit code

A 64-bit process cannot load a 32-bit module into its process space, and a 32-bit processes cannot load a 64-bit module into its process space. The only way that communication can happen between 32-bit and 64-bit modules is through interprocess communication (IPC).

In other words, 32-bit and 64-bit processes can exchange data using IPC techniques such as out-of-process COM, sockets, Windows messages or memory mapped files.

A 32-bit software product contains the main module which calls into the DLL. As long as both the main module and the DLL are 32-bit processes the product can run on both 32-bit and 64-bit platforms. If both the main module and the DLL are migrated to the 64-bit platform, then they can both run in a native 64-bit process. However if only the main module is migrated to 64-bit, it will not be able to load the 32-bit DLL.
The best way to migrate such a product to a 64-bit platform is to migrate both the main module and the dependency DLL, but if the dependency DLL cannot be migrated then it cannot be loaded into the 64-bit process and the application won't work.

Alignment in Memory: The alignment of data in memory is different for 32-bit and 64-bit processes. This means that your more complicated custom data structures may be serialized by a 32-bit process in a way that is different to that expected by a 64-bit process, and vice versa.

Datatype Size: The differences are mainly in pointers which are 32 bits long in 32-bit platform and 64 bits long in 64-bit platform. The pointer-derived data types such as HANDLE and HWND (Windows) are also different between 32-bit and 64-bit versions.

More on Accessing 32 bit DLLs' from 64 bit code

Read more ...