Sunday, October 11, 2009

Launch Jboss/tomcat from Eclipse

Today I tried to configure jboss within eclipse to use JSP in one of my own project. On running, I landed up with a strange exception

2005-05-27 21:35:54,421 ERROR [SocketListener0-1] compiler.Compiler (Compiler.java:412) - Javac exception
Unable to find a javac compiler;
com.sun.tools.javac.Main is not on the classpath.
Perhaps JAVA_HOME does not point to the JDK
at org.apache.tools.ant.taskdefs.compilers.CompilerAdapterFactory.getCompiler(CompilerAdapterFactory.java:105)
at org.apache.tools.ant.taskdefs.Javac.compile(Javac.java:929)
at org.apache.tools.ant.taskdefs.Javac.execute(Javac.java:758)
at org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:407)
.....
....

It took my 2 hours to setup JAVA_HOME even though it was setted up right. I changes the registry entries because on googling someone specified this as a solution.

But finally what worked was copying $JAVA_HOME\lib\tools.jar under $JBOSS_HOME\server\default\lib

So this post is for saving time for those who are also struggling with the same problem. Its worth giving this as your first try and I am sure it will take you through.

Sunday, September 14, 2008

Its been a while, but I am still not bad in probability

Few days back, one of my friend who like to solve Data structure problem asked me an interesting probability problem. I thought, ah probability, I am no more good in it. Its around 7 yrs I dint even touch its basics. And I am not in profession to make money by betting in stock market based on the probability of any stock to rise. 

Today is Sunday. I went to park for a walk with school friends and had a fantastic breakfast. I was feeling fresh. I had nothing much to do. Suddenly the thought to try out the problem ran into my mind, and as I was free and in good mood so I thought to give it a try. 

Here Is the problem:

Assume your computer is reading characters one by one from a stream (you don't know the length of the stream before ending). Note that you have only one character of storage space (so you can't save the characters you've read to a something like a strong). When you've finished reading you should return a character out of the stream with equal probability.

Everybody has different approaches but I always go to the route by taking example.

Question ask to select a character from stream in such a way that probability of selecting any element in the stream is same. It is conditioned by the one character extra space that we can use. 

Lets consider that the stream has 5 elements:
a, b, c, d, e

As the stream has 5 elements then everyelemet should have 1/5 probability to get selected.

First solution:
Read a and keep it in buffer. Read next char(b) . Get a random number from random generator, which returns 0 or 1 with equal probability. we have random generators built in in all the languages. If zero (0) comes, don't swap b with a but if 1 comes, swap b with a. Do the same for rest of the characters C, D and E.

Lets see the probability:
  • A: it would be the final choice if random generator returns zero(0) for all other characters in the stream.  p(a) = 1(a) * 1/2(b) * 1/2(c) * 1/2 (d) * (1/2)e = 1/16 
  • B: B final selection depends only on character c, d, E. Not on A. B would be the final choice if random generator returns (1) for b and (0) for characters c, d, e.                                 p(b)= 1/2(b) * 1/2(c) * 1/2 (d) * (1/2)e = 1/16
  • p(c) = 1/2(c) * 1/2 (d) * (1/2)e = 1/8
  • p(d) = 1/2 (d) * (1/2)e = 1/4
  • p(e) = (1/2)e = 1/2
You see, as we go down in the stream, probability increases. And the reason is there are less characters to replace it. E has the highest probability as there is no more character to replace.

This is definitely not required. What we have noticed,
For a, there are 4 more character to replace it if it get selected as final choice.
For b, there are 3 more character to replace it if it get selected as final choice.
..
..
For e, there are no more character to replace it if it get selected as final choice.

Lets modify it. If we our self make selection of a character difficult or less as we go down the stream, we can get the equal probability.

Final solution:
As we go down the stream, decrease the probability of swaping a character.
We can use random function like random (1, n) where the character will be swapped only if it random(1, n) returns n. So its probability will be 1/n.

Now, the probability for each alphabet to get selected for swapping will be
p(swap A) = 1/1
p(swap B) = 1/2, p(do not swap B) = 1 - p(swap B) = 1/2
p(swap C) = 1/3,  p(do not swap C) = 1 - p(swap C) = 2/3
p(swap D) = 1/4,  p(do not swap D) = 1 - p(swap D) = 3/4
p(swap E) = 1/5,  p(do not swap E) = 1 - p(swap E) = 4/5

We are almost done. Now lets calculate the probability of each character to come as random number as final answer from stream.

A: = A is selected as swap. And no other character is selected for swapping.
     = p(swap A) * p(do not swap B) * p(do not swap C) * p(do not swap D) * p(do not swap E)
     = 1/1 * 1/2 * 2/3 * 3/4 * 4/5 = 1/5

B: = p(swap B) * p(do not swap C) * p(do not swap D) * p(do not swap E)
     = 1/2 * 2/3 * 3/4 * 4/5 = 1/5

C: = p(swap C) * p(do not swap D) * p(do not swap E)
     = 1/3 * 3/4 * 4/5 = 1/5

D: = p(swap D) * p(do not swap E)
     = 1/4 * 4/5 = 1/5

E: = p(swap E) 
     = 1/5.

All the characters has equal probablity of getting selected. 

Monday, February 18, 2008

People Never Fail....They Just Give up.

Today, while browsing via blogrolls, I landed to a profile of a guy who is an exception to this world, who is blessed with strong will power. Title is just not a quote to me, I mean it now.

The guy I am talking about is Rajat Mishra, who joined NDA. He had to left the army because he had an accident in which he lost his right hand. Despite of sudden and steep change in his life, rajat dint loose. He decided to learn to write from left hand. Not only he learned to write from left hand, he also cracked GMAT with commendable 740 score. He cracked the interview and joined ISB. Just after 20 days, he found ISB not his cup of tea. He left it and joined IIMA for 2 year mba.

Hats off to you dude. You may find him here.

Now it make sense to me.....People Never Fail, They Just Give up.

Monday, August 06, 2007

Suddenly felt to write random.

After a while, Today, I don't know why, even I have other pending work inline, but I am feeling to write something. I don't have much to write except my presentation last week in the company.
A week before last week, I got the mail from HR to give presentation on our tech forum activity in company. Actually here everybody present something and last week, it was my turn. Before this, I was a part of good audience when technology geeks of Wirkle Inc., my company, presented on core IT related technical topics.

Was I also going to present some technical topic ?.

Actually other then technical topics, companies case study always inspires me and force me to move ahead with positive energy. So, I decided to present a case study on YouTube which was recent revolution after myspace in internet space. Here I go...



Although its not very stylish and colourful but I tried to aggregate all facts and figures. It could be a bit motivational and who knows, tomorrow, maybe anyone from us, make another youtube.

Friday, April 27, 2007

Convocation.....Most awaited moment

After two years of long time gap, last week, we were in college again on the occasion of Convocation ceremony for our batch (2005). Everybody was looking more mature, responsible and importantly more disciplined. Guys, who were always seen in torn jeans and funky t-shirts, were in formals.




Aren't they looking like the top professionals of industry gathered at one place to discuss about some important issue?





Convocation is most awaited by all and the reason is you meet all your friends under the roof where you met them first. You meet your classmates and batch mates to whom you could not meet because after college, some left the town, some left the country and those who still in the same town go early and come late from office. But it does not take time to have fun with them once again


Convocation ceremony started and we all were sitting in convocation hall. Around 200 people sat in black & red rob with pin-drop silence. We were being addressed by top most persons of industry. There was one lesson common in everyone's speech and that is responsibilities towards society. We take so much from the society and when it comes to return to the society, we starts to blame our system. According to Dr A.P.J. Abdul Kalam, Indians are the most ethical and disciplined citizens in the world when they are in foreign but when they come to India they don't bother breaking the laws. Vice Chancellor GGSIPU University talked about lack of vision when a youth come out of the college and that is the reason of increasing attrition rate in the industry. While talking about engineer's capability to take quick decision, he gave us an example of two friends who were in forest. Suddenly a lion came in front of them. Both were frightened because they were not prepared for this situation. First person said, to save our life we need to run faster then lion. He asked second person, Do you think we can run faster then lion? Can you guess what he had replied? He replied, I don't need to run faster then lion. I just need to run faster then you.


Finally degree distribution event started and after waiting for a while, I was a graduate from Delhi University.


Saturday, April 21, 2007

Back in writing mode

Hello,

yes, its 1 year 3 months and a day since my last post but its better to be late then never.

Right now I don't have anything to write but from this point onwards I promise that I will be more regular and will try to keep this blog updated.

Thank You,

Friday, January 20, 2006

102 keys and me

I know u must be curious about the name I have given to this post. So I gonna do that first. Before u ask me question to put such a absurd name, let me explain the meaning. 102 keys are the keys on which I spent my most of the time in last 180 uneven days. It means its all about my professional life as a software engineer.

I am a production and industrial engineer. Generally people ask me why I shifted from hard core manufacturing to white collar job. I just simply say that i shift my line for four years and now i am on the track, i wanted to be. Starting from very first addition program of two integer to a big mobile application in Wirkle (Company with which i started my professional career), journey was full of different experiences.

I think before describing 102_keys_and_me i need to explain about Wirkle. Wirkle is a startup company by some crazy people of IITS, DCE and desi punjab(Thapad). Word crazy really suits them because one needs to be crazy when he/she think to invest his/her lovely nights to build up a company.

When i got opportunity to work with these crazy people, then I thought a bit. I still remember the night when i met one of them at ansals plaza. That 2 to 3 hours of meeting was enough to change my mindset and after that meeting i was a wirkelite in papers and with my mind also.

From the very first day till the day of launch, ..................launch oooooo I forgot to mention that I am writing this blog because Wirkle have launched its alpha version in the market. One can check this at www.linknsurf.com. Now we have achieved our first milestone but still long way to go.
“when your aim is big enough then small success and small failures shouldn't count".

Starting with Wirkle wasn’t easy at all. Here we have started with a team of five. All are exceptionally good except me (i mean, i am not an exception). With time things become little easy. By the time coming late in the morning and working late nights has become habit.
As the time passes away these 102 keys got familiarized with the feel of my fingers and under some brilliant minds, some characters that we wrote has turned up into a mobile product. But there were lot other things involved between this. Discussions (so called Gappe) from morning till afternoon and then some takk-takk on keyboard from afternoon till night. Some parties are definitely unforgettable like the one we had at E-Zone. Fights among colleagues while selecting a gift,late night movies to get rid of the whole day frustration and then tripling on bike were some unforgettable moments here in Wirkle.
When you are working in a team, that team becomes like your family and with your family u share each and everything. There are some buzzwords that u come up with, in each society or in each family like,

“Uncle Chips from kitchen se" – less salad in big polythene at lunch time,

"ooooooooooooooooooooo" – easy to come out from an argument,

"I need one version in CVS today" – Daily evening punch line from immediate manager,

"kyon" –pet word by one of my team manager

...................bla bla bla.

Finally 6month has been passed out and we have achieved our first milestone. In the past six months I learned a lot, I enjoyed a lot, I got frustration a lot, I fought a lot, I talked a lot and I missed my college time a lot.