An Effective way of Removing duplicates in a file
Posted at 10:46AM Nov 08, 2009 by Anurag Sharma in Personal | Comments[1]
Dealing with a Strange Java Problem
Here is a strange problem encountered by me while experimenting with Java. Have a look at the following code sample:
interface test {
void fun();
}
public class Test implements test {
public void fun() {
System.out.println("Test.fun() called");
}
public static void main(String[] args) {
new Test().fun();
}
}
Can you find any problem with the above code sample? Well there really isn't any problem with the above code. Still when you try to run this on Windows systems the execution fails for Test class ( i.e. >java Test) throwing exceptions like:-
java.lang.NoClassDefFoundError: test (wrong name: Test)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.security.AccessController.doPrivileged(Native Method)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.security.AccessController.doPrivileged(Native Method)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
Exception in thread "main"
Exception in thread "main" Java Result: 1
And adding to the surprise, this program runs absolutely fine on Linux and other Unix based systems! Ok so lets try to dissect the program and figure out what the problem is with this. Here is the possible explaination which I came up with. Observing it a little carefully you can observe that the name of the interface is 'test' and class is 'Test' this makes them differ only in case. But what difference does it make to us? java is of course case sensitive, so we are free to chose names like that! Well the answer is that, although java is case sensitive the underlying OS ( Windows) is not. Therefore the compiler (even though it wanted) couldn't create two separate .class files (one for interface, and other for the implementing class), because the other class file over-writes the previous one. In short, this problem arises because after compiling the above code, two class files: test.class and Test.class map only to a single file on windows, not two unlike the unix systems. So be careful while getting trapped in such of hard-to-find bugs!
Posted at 12:56AM Nov 08, 2009 by Anurag Sharma in Personal | Comments[1]
Getting Started with OpenSolaris 2009.06 Desktop

Here is My GNOME(OpenSolaris 2009.06) Desktop's screenshot, to prove that theres nothing now which cannot be achieved in the world of Open-source. It now is no more limited to the community of computer geeks, but its increasingly becoming extremely user friendly proving it much suitable for the beginners as well. The time is gone when one needed to type long and cryptic commands in order to do anything they want on Linux & Unix systems. Though the command line alternatives are always there, leaving an entire world for the user to explore and learn! Everything is now offered in much more interactive and highly customizable GUI.
Thats the beauty of open-source- it can give you exactly what you want.
Open-source products including Linux and OpenSolaris opens itself to
change by anyone who uses it thereby giving the freedom and power to
users. There are multiple Window Managers available for using with it.
The most commonly used are -GNOME and KDE which generally comes integrated with most of the linux distributions as well.
Lets
begin with our familiarisation with GNOME, OpenSolaris 2009.06 Desktop
( but this might help you in other linux distros as well)
It
displays a menu bar at the top containing menus for Application, Places
and System on the left side of the bar along with the tray icons of the
processes and a calendar, sound control and the Username being on the
right side of the bar.
And a status bar at the bottom of the screen
with the icon to Show the empty desktop minimizing all the currently
opened windows, tabs of all the currently opened windows, a Desktop
Switcher showing the available desktops and finally a Trash (where the
deleted files reside giving option to restore back the accidently
deleted files, until manually cleaned).
- Application Menu: It contains Set of the applications installed and currently configured to be displayed in the menu format in different categories. It comes packed with a range of open-source applications preinstalled, like firefox for web browsing, Mozilla Thunderbird as the email client, Pidgin as the chatting messenger, Totem and Rythmbox for audio/video playing, many Image editing and viewing tools and a set of GNOME games!
- Places Menu: It presents links to some of the predefined locations so as to reach there quickly.
- System Menu: It presents the system specific tasks and configurations
Application and System menu can be manually altered by right clicking-> Edit Menu option.
Any system related information about the running processes or the present system memory and network usage etc. can be found anytime in Applications->System Tools->Performance Monitor.
Opensolaris presents with an exhaustive list of open-source software for anyone to download from anywhere in the world from its central repository using IPS (Image Packaging System) . This can be done in either of the following ways:
- System->Administration->Package Manager
- using command line utilities like apt-get :
- pfexec pkg install <package_to_install>
Some of the other Free utilities in which you would be interested to install are:
- Opera (a web browser)
- Netbeans IDE ( for programming in JavaSE, JavaME, JavaEE, C, C++, Javascript etc )
- openssh ( for enabling remote login into the machine)
- Evolution Mail ( another email client like Evolution)
- Avant Window Navigator ( enables a cool looking, highly customizable docking feature much like MAC )
- GVIM text editor ( a GUI based vim text editor, for the people who are addicted to the cool and simple, our beloved VIM ! )
- GIMP the Image Manipulation Program
More to cover in subsequent posts.
Happy Open-Source!
Posted at 07:11AM Oct 07, 2009 by Anurag Sharma in Personal | Comments[1]
GIMP (the GNU Image Manipulation Program) my favourite Open-Source Image Editor
This tutorial is meant to remove fears from the hearts of people who
fear working on open-source tools. GIMP is an open-source Image
manipulation tool used exhaustively, but not that much common with the
students especially here at my college. It has an exhaustive set of
tools to match any of your image editing needs, with and extremely
intuitive interface and very easy to learn.
So lets get started. Here I present my first tutorial for building a cool name template with shiny table effect as shown below, to let them know how easy it is to work with GIMP for common requirements of students.

1. Install and start GIMP editor in your favourite operating system. This is fairly easy in case of OpenSolaris and Linux flavours like Ubuntu, Fedora etc.
2. File -> New -> Choose desired size ( default 640*400 works fine for me ), and click OK
Now a white background is visible in the Image window.
3. Select Blend Tool and Gradient as FG to BG. Then keeping the CTRL key pressed drag a line from top to bottom on the image and you shall find something like this -->


Filters -> Blur -> Gaussian Blur -> Select horizontal and vertical blur radius as anything between 12 px - 20px each. and click OK
6. Select Layer2 and choose Color as Green from the color chooser.
7. Select Filters-> Distorts -> Emboss -> select funtion as Emboss and Azimuth, Elevation and Depth to any suitable value ( 30, 45, 20 respectively in my case)
now this will look something like this->

9. Now Select Layer3 -> Tools menu -> Transform Tools -> Flip Tool -> Select Flip type as Vertical and click on the text. This is invert the image.
Select the Move tool from the toolbar and position the vertically flipped text few pixels below the original text. It will look like this now--->

11. Select Layer3 and then select Blend tool from the tool bar with Gradient as FG to transparent and using CTRL key draw a straight line from bottom to top anywhere in the image. This is make the reflection text only partially visible, like this->


Posted at 11:31AM Sep 04, 2009 by Anurag Sharma in Personal | Comments[0]
Yet another tremor shook the souls at Bhubaneswar
, which struck me when I was peacefully
asleep ) , still not strong enough to make my nerves active. It took me
another 10 minutes to realise what had happened. I could hear students
shouting and yelling ( But this is not new to our hostel. We have full
freedom of expression here
). But as the case with me, majority of
us got to know about the event from the fellow mates, only after it was
gone ( just like Indian Police! ). But whatever the case may be, this
event triggered many hot talks and fuming discussions here among boys.
I could listen to few words which popped up every now and then like
-'earth-quake','tsunami' ( what ? TSUNAMI !!! I really am scared of
it.. Can I make a boat out of my study table? or using bed would be
better idea?
)These increasing terrorist activities, bomb blasts every now and then, and now earth-quakes, tsunami, drastic weather changes, global warming, pollution, Swine Flu! are they not signals by mother nature indicating something? It sounds like a threat to me. We all shall be wiped off from the crust if we continued our greedy actions..
But at such hard times, one deeply feels the need of the loved ones to stay next to us. It makes one realise the true worth of relationships.
Posted at 04:00PM Aug 12, 2009 by Anurag Sharma in Personal | Comments[0]
A Leap towards Open Source... We too are in the race !
I really appreciate this campaign and am happy to be a part of this
. I hope,
soon I would be accompanied by all my fellow mates in this effort.Posted at 11:50AM Aug 08, 2009 by Anurag Sharma in Personal | Comments[1]
My adventures with Java
We never realized
that among so much fun and enjoyment in our Computer classes we were
actually making our way through programming fundamentals and later on
most of us would land up in there lives at places which would
inextricably attached with programming. Well that was the beginning of
programming for me, I would rather say.Java... I remember I heard it for the first time in class 7th from my computer teacher. I didnt know anything more than just its name. At that time computers meant no more than a dull boring Black screens placed in our school labs, which knows some DOS commands, for me. Java seemed interesting..
or rather
'sounded' interesting! I decided to learn it sooner or later. But then
we make so many plans in our lives when we are young. And as it happens
with me always, I forgot even that. It wasnt until my B-Tech 1st year,
that again the term 'Java' got refreshed in my mind. Actually it was an
informal geeky (rather we all were trying to sound as geeky as
possible!) conversations among friends at college hostel. There one of
my dear friend put up this term & again I was reminded of my plans
of childhood
(sounds comical)Well then it was the summer holidays of 2nd year and then I decided to try my hands out on something new. And what else can be it other than Java at that time. I just dived my college library and came out satisfied with a thich 1000 pages book on Advanced Java in hands. I happily took it home and then spent 2-3 days just to understand its starting 2-3 pages.
It began
with Multi-threading !!! that was the first topic I started with!anyways.. it happens.. I kept on trying and consistently practicing all the programs and soon I had a large collection of my Java programs and gradually the 4 letters of 'Java' started getting clearer in my mind. And just few months more and I was the champ in Java among our friends !! ( i know I boast sometimes ) Another friend Raju, who started with C# at nearly the same time when I picked up Java, too started making cool applications in it. We used to spend hours together competing with each other, challenging each other on programming problems. He used to do it in C# and by now you all very well know what language I used
... This is called a healthy beginning. Later I self-studied JavaME an
JavaEE, created applications ranging from stupid games to challenging
problems. Here are few of my startup programs in Java. freely available
and distributable, thats what open-source is all about! -
)Posted at 11:26PM Aug 03, 2009 by Anurag Sharma in Personal | Comments[0]