Friday, May 14, 2010

Screen capture - Java

This might be very helpful for GUI developer in java. At times its hard to figureout the some error happens in the user end. I mean, End user usually just complain that while clicking so and so button or tab or something it failed. In those cases if you have users screen, you can guess something. To do that, you can make the following code as an API and store screen shot in your log location and you can verify them later.

License key generator for Java applications (free)

Just a quick note that if you happen to be looking for a license key generator (or "license key manager") for a Java desktop (Swing) application, I've been taking a look at the TrueLicense library on java.net, and although it is several years old now, it seems to work well, and the author certainly put a lot of time and thought into it.

As a word of caution, I did find the author's tutorial difficult to read, so I highly recommend looking at an introductory doc written by Martin Paulo. (Just search for his name on the TrueLicense homepage and you'll find a link to that doc.) After reading that doc, the author's tutorial made more sense to me.

I don't know how many people need a Java license key generator, but if you're in the market for one, and "free" (or donation-ware) is your right price, I recommend taking a look at the TrueLicense license key generator for Java applications.

Java Store update

In a related note, the "Java Store" is still in beta. If you haven't heard of it before, the Java Store "is an application storefront that provides an easy and secure way to discover Java applications for your desktop." I don't know what they're doing for software licensing and license management, but I thought I'd mention this "store" again here today. I appreciate what they're doing, I just wish this was available a long, long time ago.

Friday, May 7, 2010

Personalize your windows command prompt

Some times you may want to customize your windows command prompt to display font color differently. I mean instead of white color font with black back groud color, you may want to display them in red color font or something else. Typically people go to window properties and choose the color. Instead you can achieve through DOS command. This is not just for a fun always, it might be useful to have unique color for the batch file/app you write to do some tasks.

Here is the help information:


C:\workspace\perl>color /h
Sets the default console foreground and background colors.

COLOR [attr]

attr Specifies color attribute of console output

Color attributes are specified by TWO hex digits -- the first
corresponds to the background; the second the foreground. Each digit
can be any of the following values:

0 = Black 8 = Gray
1 = Blue 9 = Light Blue
2 = Green A = Light Green
3 = Aqua B = Light Aqua
4 = Red C = Light Red
5 = Purple D = Light Purple
6 = Yellow E = Light Yellow
7 = White F = Bright White

If no argument is given, this command restores the color to what it was
when CMD.EXE started. This value either comes from the current console
window, the /T command line switch or from the DefaultColor registry
value.

The COLOR command sets ERRORLEVEL to 1 if an attempt is made to execute
the COLOR command with a foreground and background color that are the
same.

Example: "COLOR fc" produces light red on bright white


For example:


C:\workspace\perl>color 7

Tuesday, May 4, 2010

Linux - Basic & useful commands

How to find CPU & Memory detail of linux
cat /proc/cpuinfo (CPU)
cat /proc/meminfo (Memory)


How to find if any service is listening on particular port or not ?
netstat -an grep {port no}
For example if you know that tomcat is running on 8080 port so to check if tomcat service is listening or not then use
netstat -an grep 8080

How to sort files based on Size of file ? ( useful to find large files in log directory to delete in case disk is full )
ls -l sort -nrk 5 more

How to delete files older than N number of days ? (Useful in delete log, trace, tmp file )
find . -name ‘*.*’ -mtime +[N in days] -exec rm {} \; ( This command will delete files older then N days in that directory, always good to use it when you are in applcsf/ tmp,out,log directory)


How to create symbolic link to a file ?
ln -s pointing_to symbolic_name

e.g. If you want to create symbolic link from a -> b
ln -s b a
(Condition:you should have file b in that directory & there should not be any file with name a)

How to find the Unix/Linux version of a particular host ?
uname -a

How to set/unset line numbers in vi editor?
To set line number
:set number

To unset line number
:set nonumber

Total number of files in particular directory

find /usr/local/perl-5.10.1 -ls wc -l


How to set an alias for complex/different commands?

alias l=“ls –alF”
alias cls=clear




/Proc file system - Various Kernel Statistics
/proc file system provides detailed information about various hardware devices and other Linux kernel information.

cat /proc/cpuinfo
cat /proc/meminfo
cat /proc/zoneinfo
cat /proc/mounts


Search the particular key word content in a file

grep -iR <phrase>
< phrase > -> word you want to search if you want to search a sentence enclose within '' (single quotes)

To make your search more faster if you know what type of files to be searche use the following


find -iname "*.xml" | xargs grep -iR <phrase>

Disk Usage listing with depth one level depth:
du -h --max-depth=1 .

First posting

Dear friends,

I've been thinking to write some technical related stuff for long time and I couldn't do that. Some how I started today and lets see how it progress further. Feel free to post your comments & suggestions on this.