Export DISPLAY on RHEL Red Hat Enterprise Linux

Writing by on Saturday, 8 of June , 2013 at 3:50 am

On the source machine

[user@sourcemachine ~] echo $DISPLAY
:1011.0
[user@sourcemachine ~] xhost +

On the remote machine

[user@sourcemachine ~] ssh user@remotemachine
[user@remotemachine ~] export DISPLAY=sourcemachine:1011.0
[user@remotemachine ~] /usr/bin/firefox &

OR

[user@sourcemachine ~] ssh -X user@remotemachine
[user@remotemachine ~] /usr/bin/firefox &

With the ssh -X option, you don’t need to worry about DISPLAY, but some applications might not work.

Leave a comment

Category: Linux

WinSCP throws the error Received too large (… B) SFTP packet. Max supported packet size is 102400 B

Writing by on Monday, 20 of May , 2013 at 6:30 pm

I got this error and found the solution on winscp.net docs.

Edit the session
Change File Protocol to SCP instead of SFTP

Leave a comment

Category: Tips and Tricks

NX Connection Issue DSA key is corrupted or has been protected with a passphrase

Writing by on Tuesday, 30 of April , 2013 at 10:50 pm

If NX Client is not able to connect to Linux VM and comes back with the following error

DSA key is corrupted or has been protected with a passphrase

You will need to follow steps mentioned in the NX Admin Guide – Section 4.4. Replacing the Default SSH Key-Pair with Keys Generated for Your Server.

Once you follow the steps of generating new keys, you will need use (paste) the new shared key in the NX Client.

#Follow the keygen steps
$ /usr/NX/scripts/setup/nxserver –keygen
$ … … …
# Copy the Key from
$ cat /usr/NX/share/keys/default.id_dsa.key
# Paste this Key in the NX Client (Configure… General Tab -> Key…)

The problem should be resolved.

Leave a comment

Category: Linux

Use Ant buildfile or a script to build your Eclipse project

Writing by on Tuesday, 5 of March , 2013 at 6:44 am

Let’s say you have a buildfile build.xml that builds your project and deploys to say Tomcat. Wouldn’t it be great to have Eclipse do that for your when you build the project within eclipse? Eclipse has this concept called Builders as part of your project properties that let’s you do just that.

  • Right Click the Project -> Properties -> Builders
  • Select New
  • Select Ant Builder
  • In the Main tab
  • Buildfile -> Browse Workspace… and select the Buildfile
  • Base Directory -> Browse Workspace… and select the Base Directory
  • In the Refreshtab
  • Check Refresh resources upon completion (recommended in most cases)
  • Select The project containing the resource or the option that suits you
  • In the Targetstab, select the desired targets from the buildfile

When you build (Ctrl+B) in eclipse, the specified ant target will be run for you and in my case, my application will be deployed to Tomcat.
If you want to run a script, you can do so by selecting Program instead of Ant Builder.

Here’s a screenshot of my Ant Builder.
EclipseAntBuilder

Did you know you could also debug your Ant Script within Eclipse.
Another great post on IBM Developer Works.

Leave a comment

Category: Eclipse,Java

Correlating Linux top output with java stack trace from a thread dump

Writing by on Thursday, 21 of February , 2013 at 12:23 am

Using the top -H command to show you the thread ids, and from the thread dump, you can correlate the thread that’s taking CPU time.

For example the stack trace will show you the ID in hex format and the top will show you the thread PID in decimal format.

Notice that nid=0x6c21 (top -H) is the same as 27681 (from the thread dump).

Here’s a thread dump snippet

“http-bio-/127.0.0.1-9090-exec-7” daemon prio=10 tid=0x000000004c433800 nid=0x6c21 runnable [0x00000000644b9000]
INFO | jvm 1 | 2013/02/20 11:51:57 | java.lang.Thread.State: RUNNABLE
INFO | jvm 1 | 2013/02/20 11:51:57 | at java.util.HashMap.put(HashMap.java:374)

Here’s the output of top -H

[root@myserver bin]# top -H

top – 15:56:17 up 5 days, 5:16, 8 users, load average: 2.16, 2.25, 3.28
Tasks: 1038 total, 3 running, 1035 sleeping, 0 stopped, 0 zombie
Cpu(s): 12.8%us, 0.1%sy, 0.0%ni, 87.1%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
Mem: 37043972k total, 35569196k used, 1474776k free, 45720k buffers
Swap: 12586916k total, 228k used, 12586688k free, 18998952k cached
3.00 00:04:50
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
27409 shivdev 25 0 11.6g 10g 16m R 99.9 30.7 1305:02 java
27681 shivdev 25 0 11.6g 10g 16m R 99.9 30.7 1304:37 java

Leave a comment

Category: Java,Linux

Eclipse Debugger Hits Unmarked Breakpoint on Exceptions

Writing by on Sunday, 27 of January , 2013 at 7:58 pm

By default, eclipse will suspend the execution on uncaught exceptions and take you directly to the code that you may not really intend to debug. To avoid that set your prefrences:

Window -> Preferences -> Java -> Debug
Uncheck Suspend execution on uncaught exceptions

Leave a comment

Category: Eclipse,Java

Shivdev Kalambi's Blog

Shivdev Kalambi is a Software Development Manager, previously a Principal Software Engineer at ArcSight/HP. With over 16 years' experience in software development, he's worked on several technologies and played different roles and contributed to all phases of projects. Non-tech activies include Ping-pong, Rock Climbing and Yoga at PG, Golf, Skiing, Swimming & a beer enthusiast.