Monday, December 10, 2012

How to install JDK 7 and set up JAVA_HOME in Mac OS X Mountain Lion

The last 2 hours have been exciting! Thanks to the complexities involved in setting up the Java development environment on Mac OS X (10.8.2) code named as Mountain Lion (latest as of today). 

Apple did something nasty after Oracle took over the SUN Microsystems, Apple announced some months back that they are not going to support the further releases of the JDK. As a result the Mac OS now doesn't come with the JRE installed by default. We have to manually install it. If you are a Java developer simply JRE won't suffice, you need to install the JDK (Java Development Kit).

Okay, that's the crappy story behind why this complexity arise now and was not present earlier. Installing JDK 7 is easy on Mac OS X. (Installing JDK 6 is impossible as of now on Mac OS X Mountain Lion, I've done some reading on this and I couldn't find a way - the main reason is Oracle has not released Mac OS compliant JDK 6 installation. If you know installing JDK 6 on Mac OS X, please post it in the comments). The Oracle guide for installing JDK 7 on Mac OS X is pretty clean so I'm not wasting my time in writing something that is already clean and clear. JDK is installed system-wide and you cannot install it on user basis. You also need admin access for this installation. Installing JDK also installs JRE on your system. 

To summarize, the steps are:

1. Go to http://www.oracle.com/technetwork/java/javase/downloads/index.html and download the appropriate .dmg file (for me it was jdk-7u9-macosx-x64.dmg). 

2. The file will take some time to download, it took me like 30 mins. The file will be downloaded in the Downloads folder, can be accessed through Dock. Double click the .dmg file and a Finder window will appear with a box - double click it too and the installation will start. That's it!! A confirmation window will appear when installation is done.

It's that simple! 

What sucks is setting up of $JAVA_HOME!! 

It took me more than an hour to figure this out! It's also because I'm pretty new to Mac OS. 

Okay so where is JDK exactly installed on Max OS? It's here: /Library/Java/JavaVirtualMachines/jdk1.7.0_09.jdk

And where is the bin folder of the JDK, it's here:
/Library/Java/JavaVirtualMachines/jdk1.7.0_09.jdk/Contents/Home/bin

And where the JAVA_HOME should point to? 
/Library/Java/JavaVirtualMachines/jdk1.7.0_09.jdk/Contents/Home

JAVA_HOME should point to the home directory and not the bin folder. 

How to set up JAVA_HOME ? The real reason I'm writing this post...

Step 1: 
Check out whether you already have set up $JAVA_HOME and $PATH. Remember the letters should be capital. Open the terminal and type the following commands
  
echo $PATH 
echo $JAVA_HOME

These will print out the current values of $PATH and $JAVA_HOME. You would probably have some value for your $PATH but it will be blank for $JAVA_HOME. 

Step 2:
$PATH and $JAVA_HOME should be present in your .profile file. This file is present in your home folder - it is the place where your terminal opens by default. If .profile file is not present you have to create it! This is the trickest part but it is simple!! Following are the steps:
  • Open your terminal and type the command vi .profile This will open the .profile file and if not present will create it. 
  • Paste the following in the file
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_09.jdk/Contents/Home;

export JAVA_HOME;

PATH=$PATH:$JAVA_HOME;
export PATH;
          • Write & quit the file by typing :wq   

          Now, try to see the values of the $PATH and $JAVA_HOME as specified in the Step 1. In my case they show the following values: 

          echo $PATH
          /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/Library/Java/JavaVirtualMachines/jdk1.7.0_09.jdk/Contents/Home

          echo $JAVA_HOME
          /Library/Java/JavaVirtualMachines/jdk1.7.0_09.jdk/Contents/Home

          Step 3:
          Verifying everything. Just once command will verify everything: 

          $JAVA_HOME/bin/java -version

          If this command gives you the Java version that you installed, then you are good to go! In my case it prints out
          java version "1.7.0_09"

          That's it!! Wasn't it simple? :)

          Sunday, September 30, 2012

          Guidelines, Tips and Tricks for buying a used car in USA

          If you are looking to step into U.S.A anytime soon, or have already stepped I would strongly suggest to get a car right away! 

          Why is it so important to get a car in U.S.A? 

          A car in U.S.A is not a luxury but a necessity. The main reasons are lack of proper public transport except some cities/downtown areas like that of NY/San Francisco. Speaking in general, the frequency of buses is less and also the routes the buses take are strange, I need to take 2 buses even if I have to travel only 6 miles. One more reason is the the way cities are spread across a diameter of more than 30 miles! It's difficult to provide a good public transport covering such a large area considering the costs, so I don't really blame the transport authorities, may be they are doing their best.

          Yeah, I wanna buy a car, what's Next? 

          First things first, answer all the following questions honestly, 
          1. What would be the major use of the car - work commute? Pleasure? luxury? Long distance travels?  
          2. Your budget? You can get a car from $2000 to $20,000 and above! Decide how much money you can lock into your car, this also goes along with for how much time are you thinking to use your car?

          Once you answer these two questions honestly, you will never go wrong with your final decision on the car you select to buy. 

          There are 2 options:
          1. Buying from a private party(some individual who wants to sell his own car)
          2. Buying from a dealer

          Both have there own pros and cons, let me explain,
          Buying from a dealer can be expensive by about $1000 to $3000 more than what you would get the same car from a private party, depending on the market value of the car. But he may give you additional benefits like warranty for 1 year or more so you return with a peace of mind. Usually dealers do a thorough check of the engine/history/condition of the car before buying a used car and putting it on sale so there is a little more surety on the condition of the car. 

          If you ask me personally, there are many many honest individual sellers out there and I think dealers rip you off! And they also rip off the seller of the car! They are there to do business! They may sell you a not-so-good car, so do not trust them blindly. I bought the car from an individual and this post is written mainly for people who are buying from a private party. If you want to go with buying from a private seller then you must consider the two best sources that I have found during my research for a used car:

          2. Cars.com
          3. Tell all your friends that you are going to buy a car!! You never know a friend of your friend is looking to sell one! Put up a ad at your workplace. Look out for "For Sale" piece of paper on the cars on your streets and a few around your house - you may get lucky!

          Even though Craigslist has many fake people/ads and you meet funny people but still as far as buying used cars goes, the honest ads vastly outnumber the fake ones. There are some tricks to search genuine used car ads on Craigslist - look out if the seller has displayed the following things in his post.. 

          1. His contact no./any phone no. -if he is a genuine seller and really wants to sell his car he would like potential buyers to call him up!
          2. Details and pics of his car - he will post a few pictures of his car as well as information of his car, the way it feels to ride, the way he has babied it, that it has stored in the garage etc etc all the things that tells us about the car, because if he really want to sell the car, he will interest the buyer. 
          3. He will mention the price he is expecting.

          If you don't find any one of the above missing, then the seller is not serious and probably you shouldn't waste your time.

          How to recognize a good deal? 

          1. Honda & Toyota and Nissan command a good resale price. They hold their value pretty well compared to Ford/Chevy any other brand because they cost less to maintain, give good fuel mileage and also the parts are cheaper  (but don't take this too seriously, the parts of Ford can be cheaper as its a USA home production) and many times the difference is not big. They are considered no-hassle cars, but this doesn't mean none of them have issues, it depends from car to car and your luck plays here. 

          2. If a seller is asking you say $5500 for a Honda Civic of 2004 with 120k miles on it, then before thinking the price is ridiculous visit kbb.com and get the fair and good price of the car. KBB and Nada are two places which will give you an idea of how much should you pay for the used car. Once you know the range of the market value of the similar cars you are in a better place to negotiate with the seller. Use the Good price/Fair price. I have seen Honda Accords and Ford Mustangs trade above the good price because they are so rare in the used markets and they get sell quickly!! - at least in LA where I live. But it all depends on how the seller has maintained the car - if the seller has really taken care of the car, always garaged, has owed it from a long time or is a single owner till now, it makes sense to pay a couple of hundred dollars more than the kbb. My point is use kbb to make sure you are not paying extraordinarily high for some car, also if it is too cheap compared to the kbb, something is wrong with the car! If something is too rosy to be true, probably it is!!

          3. Check the regular maintenance schedule specified by the company of the car you are considering, you can find the schedule here. You may want to negotiate if you have to do some regular maintenance work soon, say like Honda Civic requires changing of the timing belt at 120k miles and if you are buying a Honda Civic that has already done 115k miles, may be you want to consider the cost of changing the timing belt to get deducted from the price seller is quoting. Also check if the specified regular maintenance has been done till the date. If there is any maintenance work that has been done on the car, ask the owner if he has any receipts to prove it. You will never know if he has really replaced some parts/oil if he isn't able to provide the receipt for it.

          4. Get the VIN number of the car from the seller over the phone/internet before you visit the seller - this is important! VIN (Vehicle Identification Number) is the unique no. assigned to every car by the manufacturing company. There are companies (even DMV - Department of Motorized Vehicles) that maintain the car history for every car and to get these report you need the VIN no. Get the carfax report and Autocheck report for the car you are considering. Autocheck has a one month plan for around $45 that allows you to run unlimited history reports. Carfax is expensive- around $30 for each car report but is detailed and gives correct/latest information, so its important to get the carfax report of the car you are serious about. There are many deals around and you can get a carfax report for like $6 per report - just Google about it. In the history report check out if the car has gone through any accidents/if an accident is reported then probably it was a major accident because an insurance claim has been done for that event and hence it has appeared in the history report. History report will also give you the history of previous owners and the miles each one has driven and also their ownership duration - you can here make out if the seller has owned the vehicle from a long time or has bought it just some days back and selling it to make money. There are flippers around and they don't thoroughly know what they are selling, it doesn't mean the car is bad, but remember that they are doing business here, unless they earn profit they aren't going to sell it to you. Genuine car sellers aren't looking for any profit, they just want to get rid of the car for a fair price. Look out if the car has been a lease car/rental car - it is not advisable to buy such a car because rental cars are driven by hundreds of people with different driving habits - not good for the engine life. So, be cautious about such cars. Look out if the report says anything about the theft, if this car has been stolen even some years back, you may want to get more information about this from the seller or if he denies it may be you want to get more information about this from local DMV in your city - but do not ignore this!! 

          Note: there are some strange people who think giving out the VIN no. will do any harm, but let me tell you there is no harm in giving out the VIN no. to the potential buyers. If the seller tells you that he will give the VIN no. only when you visit him, make an attempt to explain him why, if he still disagrees, you should not consider visiting him unless he is very close to where you live/work. 

          4. Get the car checked from the mechanic for the condition of the engine and integral parts. FireStone does a visual check which costs around $20 but I would recommend a detailed check (say 80 or 100 point check) through some experienced local mechanic (check yelp reviews to find who is good around). You will come to know about the possible wear and tear of the various parts and you will get an edge in negotiating the price of the car. If there is a serious damage to the engine or the repair costs are above $1000 you may want to drop the deal, ask the mechanic frankly that if he feels that this car will have periodic repairs? During one of my visits to Firestone, the mechanic missed out that the engine doesn't accelerate properly when the accelerator is pressed down during his test drive and I was so concerned about anything related to engine that I asked him to take the test drive again with I sitting next to him. In that round I asked him to accelerate fast and yeah he felt it! When we came out he frankly suggested me he can work on the spark plugs/other stuff that may improve the condition but not totally remove the problem as it was the inherent engine problem because of the way engine was  used till now and frankly suggested me not to go with the car! Driving to the mechanic and spending a hundred dollars can save you thousands of dollars, lot of time and headache!


          Closing the deal..

          Now that you have finalized buying the car, don't make any delay in paying the seller because if the car is really good then there are others waiting in line if you don't get it. And who the hell has time to go through the whole process again to find a good deal!! Bah! But here are a few things you should make sure

          1. Title of the car is the piece of paper that tells us who is the current owner of the car. Check if the title is in the name of the owner and if there is any other name listed along with the person from whom you are buying the car. Say if his wife's name is also included in the title, then the car belongs to both him and his wife and you need to get signatures from both. So, before you pay the money meet in person to all the owners of the car and make sure they all want the car to be sold.

          2. Smog check: It is mandatory by law that the seller does a smog check before selling the car. Look out for coupons in you local area, it costs around $30-50. The smog inspection center will hand over to you the smog certification if your car passes the test. You need to show this certification to the DMV while transferring the title to your name. 

          3. Most of the private sellers ask for hard cash. That is okay unless the sum is too large like more than $7-8k. The seller has to fill in your name in the section of buyer of the vehicle on the same title and also write your address. Then all the current owners have to sign the title. Only after your name is mentioned on the title and all the current owners sign the title place the money on his hand. Remember, there have been cases when the buyer is looted at the time of payment and also physically injured. Tips - select a public place like starbucks to pay the money, take a muscular friend with you, be close to the police station if possible and get the contact no. of the nearest police station. I exchanged the money right in front of the bank from where I withdrew the money. A better place would be inside the bank next to the security with a gun! lol..just kidding :) Once the money is being paid, get the title, check whether he has signed the transfer of title section, I guess every owner has to sign twice, and walk home happily. 

          4. The seller has to intimate DMV that he has sold his car in 5 days from date of buying the car(transaction) and buyer has to then visit the DMV and carry out the title transfer process in 10 days from the date of buying the car (transaction). Now-a-days the seller can do everything online, but you need to visit to the DMV for signing the title transfer form, submit the smog check doc and pay the title transfer fee. You need to register the car with the DMV if the registration period has expired. You need not take your car to DMV for title transfer! I didn't! You need not have car insurance for title transfer! I didn't! 

          More tips!

          1. Search someone close to your area, it will save you a lot of pain of travelling to the car owner only to find the car is not worth buying. Make sure you have a friend who has a car and you can reach the seller immediately. If you plan to visit all the cars on weekends then you may miss out all the good deals. All the good cars are sold in a single day!! Yes!! I have missed out many good deals just because I couldn't physically reach the seller in time!! And it is important to test drive the car yourself before buying it.

          2. Meet all the owners of the car at least once and get the confirmation from them that they are willing to sell the car. My friend encountered a guy who claimed that his girlfriend owned the car and she will sign the title and let him handle the finances. My friend denied it saying he will hand over the money only to the person who is listed on the title and to no one else - and he was saved because of that! The car turned out to be a stolen one and the person was someone who flipped cars. 

          3. History reports don't give you all the information. There are tricks to hide things from appearing in the history reports. I have come across the car whose history report tells me that it had only a single owner since the car was first sold but in reality there were 3 owners of the car! And the seller told this to me himself! 

          4. Look out for the clean title, especially if you are looking to sell the car again. If a car is involved in an accident and the repairs of the car is more than the market value of the car then the insurance company marks it as salvaged title. Salvaged title cars have had serious accidents in past and there could be structural/physical damage to the engine which may crop up anytime! Strictly stay away from salvaged title cars which are newer, because when the cars are new they have good market value and still then the car was titled salvaged means that there was a serious accident with damage more than the market value of the car. 

          5. I would stay away from cars who have been in accident. When an accident is reported on the car history, you don't know whether that was just a small incident in the parking lot or a major accident on the freeway! Every seller tells it was a small fender bender. In more than 150+ posts I have visited on craigslist while buying my car, I have never met any seller who told the accident was major one.

          6. Give more importance to mileage than the age of the car. I would go with a 2003 model with 90k miles rather than 2005 model with 120k miles on it. But that's just me. 

          7. Check a few videos on youtube what to look out for during the car inspection. 

          8. You can find killing deals in car auctions! But not everyone can buy at car auctions. You may need to find someone who has a license to buy from auctions and buy from him paying him some money for his help. But the drawback is you cannot take it to the mechanic and test it, even sometimes you cannot even test drive the vehicle (that's what I have heard). Sometimes, all you can do is just kick the tire! So, its all luck! 

          Happy shopping!

          Sunday, March 25, 2012

          Searching a song by singing into the search engine!!

          I was thinking about a song to search but I didn't know its lyrics so that I can search it through Google. And then I thought of this - can't we search songs singing back into the search engine? Wouldn't it be nice to search music, songs, any kind of audio using an audio input? And the search began to satisfy myself on this question..

          I searched internet for any resources/pointers I can get to any such search engines already built or any papers/thesis/reasearch work going on in this area and my search brought me to this paper: "Music Search Engines: Specification and Challenges". And I was enlightened by the research going on in this area since 1999. After searching a bit more I finally found out one website where we can search a song we want by singing or even humming into it! Check this website: http://www.midomi.com/. Midomi is a wonderful search engine that searches audio/music/songs using an audio input! You can not only sing into it, but it is effective even in my very case when you don't know the exact words/lyrics - you can search by humming into it! Or even just by whistling into it!! Isn't it amazing?

          It doesn't just limit you to that. They claim to have a very good database of songs of all languages and genre but I must say they aren't strong on songs other than English language. But one interesting thing is that you can record the song for yourself and that gets added in their database. After that, when someone else searches the same song by singing/humming/whistling into their search engine, it produces your song!! At Midoni, you can create your own songs by singing into it and then get discovered by others who search similar audio/song.

          To those retards who are thinking this is paid review or something like that ~ it is not! I was fascinated by the idea and so happy to find such a search engine already built that I couldn't help it sharing it with my readers. There may be other search engines doing the same and probably better and I would be very happy to know & use them. Happy singing!! :)

          Cheers!