Configuring Eclipse to use a JDK at a location with spaces in it

September 25, 2008

I was setting up my Eclipse environment with some new plugins today and ran into some trouble, which seems to have bothered many souls as I gather from the posts I found when trying to fix the problem.

Some tools/plugins/features in Eclipse may need to use a JDK rather than a JRE. Sometimes you may even wish to switch between different versions of the JRE or JDK being used since typically 1.4, 1.5/5 and 1.6/6 are all present on a developers’ system at different locations.

I got a mesage from a Maven plugin which said that it needed a JDK to be used to run Eclipse instead of a JRE that it was currently using. Well, this shouldn’t usually present much of a problem. You can choose the virtual machine used to run Eclipse by passing the -vm argument to eclipse.exe. What’s usually needed is something like “eclipse.exe -vm c:\jdk1.6\bin\javaw.exe”. Mind you, javaw.exe is used when you don’t want an associated console window.

I did have JDK 1.6 installed. But it was installed to “C:\Program Files\Java\jdk1.6.0_07″. That, it seems, is the default location. The space in the path caused big problems. I tried quotes\no quotes and other magical incantations to get it to accept the argument with a space but to no avail.

So instead of using the command line switch, I put an entry into eclipse.ini which is in the same directory as eclipse.exe. But this didn’t work either.

Finally, what did work was that I started command.exe (the 16 bit DOS shell) and navigated to the JDK directory using “dir /X” for help which shows names generated in the format “C:\PROGRA~1\JAVA\JDK16~1.0_0\BIN”. Perhaps you remember coming across such filenames.

Anyway, the older 8.3 style directory name worked! My final eclipse.ini is posted below.

-showsplash
org.eclipse.platform
–launcher.XXMaxPermSize
256M
-framework
plugins\org.eclipse.osgi_3.4.0.v20080605-1900.jar
-vm
C:\PROGRA~1\JAVA\JDK16~1.0_0\BIN
-vmargs
-Dosgi.requiredJavaVersion=1.5
-Xms40m
-Xmx512m

I was using Windows XP with SP3 and Eclipse 3.4. There is likely to be a better solution that I missed. If you have it or if this post helped you, please leave a coment. :)


Firefox 3 – The awesome bar

September 25, 2008

A new update to Firefox has just been made available. An up-to-date version should now be at 3.0.2. Update soon if you have not been auto updated already.

Incase you are  still on the 2.x version for Firefox, you should know that the 3.x versions have greatly improved performance for JavaScript based apps (besides other things) and that means things like GMail, Yahoo Mail, Google Reader etc. that you use regularly.

It also has this great new address bar called the “Awesome bar” because it’s…awesome. It remembers the frequency with which you visit URLs and predicts the site you want to visit from just the first few characters you type in. It doesn’t even have to be characters of the URL from the begining. It can be keywords which occur in the middle of the URL as well. And it can be a word in the title of the page as well! And you have to do absolutely nothing to configure it since it is enabled by default and gets more accurate as you use it.

Awesome, isn’t it?

Yes, Google Chrome, Google’s official entry to The Browser Wars, has come along and it may have some fine features as well. But it’s just not mature enough for me yet. Most importantly, it doesn’t have all the addons that Firefox does at present. But if Google is backing it, Mozilla will sure need to work hard to keep the users that have migrated to Firefox from IE over the last few years.

What Google would now like is that Chrome improves to the point that full fledged browser based applications start replacing desktop based apps. Apps, which are not dependant on the OS or browser that they are running on. Apps, which result in revenue to Microsoft.


New feature suggestion for Picasa and GMail for easier exports

September 25, 2008

Got hundreds of photos from parties, birthdays, marriages and outings strewn around on your hard disk? You’re probably missing something if you’re not using Google Picasa to touch up and organize them. It has some very cool features and a really slick UI.

Well, here’s something I miss in it. Picasa 3 Beta is out but they still don’t have a feature which would allow exporting images in GMail attachments into Picasa web albums directly.

Picasa’s suggested way to get images from GMail is to download the pics to the hard drive, have Picasa scan them into an album and then upload them to Picasa (the tool for this feature is very well done!).

But I don’t see what could be keeping them from implementing a page in GMail that would show thumbnails of images grouped by email alongside a button to export selected images to Picasa with an album title. A little bit of intelligence can be added by providing a filter that searches for images that can be identified to be from a Digital Camera by looking at the EXIF header or whatever kind of metadata the image file has.

Why would this be a great feature? Because everyone I know seems to have many photos “somewhere” in their GMail account that were emailed either to or by them. Only a few of them use Picasa. If they see the easy-to-use feature suggested above, not only will GMail help them organize things better, it will also push adoption of Picasa with people.

I suppose this feature needs to be implemented (mostly) by the GMail team rather than the Picasa team.  I sure hope somebody is at least thinking about implementing this already. I, for one, would find it useful.


How to split a file, process the pieces in multiple threads and combine results using a shell script

February 11, 2008

Say you are in a situation where you have a file with a huge number of records to be processed and the processing of one record does not need data from the processing of previous records (ie. a perfectly paralellizable situation), what can you do to speed up things? Well, here’s what I did when a client recently made a request for statistical data for 300K records instead of his usual request of 20 records as the program that we had earlier made for the purpose wasn’t really made to run fast and wasn’t multi threaded.

Use the “split” command to split a file by number of lines into an appropriate number of files depending upon the configuration of your hardware. Use the “-l” option to specify the number of lines in each file. Then run multiple instances of your program to process the different files in parallel using an “&”. Use “wait” to wait for all background tasks to end. And finally when things are done, merge the different output files together with “cat” in append mode. Voila! Things finish much, much faster.

I used the above steps to make 20 files with 15K lines each since the server I was running the script on was a Sun Solaris 10 T2000 system with 32GB RAM which has an octa-core processor supposedly capable of running 32 threads in parallel. It worked like a charm!

Sample script follows:

split -l 15000 originalFile.txt

for f in x*
do
runDataProcessor $f > $f.out &
done

wait

for k in *.out
do
cat $k >> combinedResult.txt
done


Java Synchronization Benchmark

February 1, 2008

Here is a very simple and straightforward benchmark to demonstrate how synchronization in Java can affect speed of execution to different extents in Java 1.4 and Java 6.

Java Synchronization Benchmark

In the attached image (click above for full size), you can see that for Java 1.4 the synchronized method needs over 700% more time to do its work compared to the non-synchronized method. But for Java 6, the difference is lower with the synchronized method needing only 400% more time to do its work compared to the non-synchronized method.

Remember, JVMs, especially newer ones do some nifty runtime optimizations that most developers are not aware of at all – like “biased locking”. This feature reduces the time taken for reacquiring a lock if the same thread is taking the lock repeatedly. There are other features like “adaptive spinning” and “lock coarsening” as well. Ofcourse, the fact is that it might just be other optimizations that are at work here instead.

Such a simple benchmark does not deserve to have any conclusions drawn from it. Infact the effect may have been greatly amplified here because the program does only an increment within the function so locking becomes the bottleneck. Such a situation may ofcourse be true in “real world” programs as well. But quite often, it is not.

I obtained this result on the single core 2.8Ghz PIV system at my desk at work.

Ideally, one should be using a multi-processor machine and multiple threads to demonstrate such effects. I would expect Java 5 to show results between those for 1.4 and 6.


Googling Sun Developer Network leads to Microsoft Visual Studio ad

December 9, 2007

I just Googled “Sun Developer Network”. Look what turned up! Hahaha! An ad for Microsoft Visual Studio 2008 which says “Defy All Challenges”. (Screenshot inserted at end of post)

It seems someone at MS Marketing realized that the realease of NetBeans 6 would be the best time to entice OpenSource platform users over to the MS side. Or atleast to make ‘em jealous with a shiny, Flash-y website. Looks like Microsoft bought itself some Google AdWords ads for that phrase. Take a look – Microsoft Visual Studio 2008 – Defy All Challenges. It’s a pretty high bandwidth kinda site though.

The IDE wars are starting to make things pretty cool for the developer community now with Sun pushing NetBeans, Microsoft pushing Visual Studio, IBM going with Eclipse and Oracle with JDeveloper. Check out some of the video demos of new NetBeans 6 features.

Googling Sun Developer Network leads to Microsoft Visual Studio ad


Firefox 2.0.0.8 released

October 26, 2007

I wonder why I have to post about every new update to Firefox. Maybe I’m just lazy.

Oh well, in case you haven’t done so already, stop using Internet Explorer, start using Firefox today! Go get the latest version (2.0.0.8) at http://www.getfirefox.com/.

Do try out the excellent addons as well. My favourite is Ad Block Plus. FoxMarks seems useful. And FireBug is awesome if you are developer working with browser based apps.

Try using some of the keyboard shortcuts like Ctrl+T for new tab, Ctrl+W for closing a tab and Ctrl+Shift+T for reopening the last closed window. They are real time savers!

Update : Seems like 2.0.0.8 was a major update and caused some regression problems which have been fixed with 2.0.0.9 which came along rather quickly.


First person to comment on Sun CEO Jonathan Schwartz’s blog post

October 9, 2007

Being the first one to comment on a blog and then feeling elated that you are the first one to comment is lame. Very lame indeed. I agree.

But what if it’s the blog of the CEO of a company that has annual revenues of $4 billion and that gave the world Java?

Yeah that’s right, I read a whole lot of blogs in the tech scene including that of the CEO of Sun Microsystems, Jonathan Schwartz.

And on the post about IBM partnering with Sun on OpenOffice.org, I happened to be the first one to comment.

Kind of reassures me that, yes, I do keep myself up-to-date on what’s happening where. Yay! :)

First to comment on a CEO blog


Vetal Tekdi trek from MIT college (photos linked)

October 6, 2007
Vetal Tekdi trek

Once in a while I feel the need to drag my lazy ass away from my PC and go trekking. I like trekking. But getting to a trekking spot is the problem. I don’t have a bike.

Not too many people realize that there’s a pretty neat place one can go trekking right inside Pune. Sufficiently cut off from the city. And close enough to make sure that getting there is no problem at all.

So one weekend, my bored self got in touch with an equally bored (Infosys employee) / (ex-roomie of 3 years from BVP) friend and we made plans to go explore the area they call Vetal Tekadi / Law college hill etc.

The day before the trek, I got a good look at the area on WikiMapia and Google Earth and drew myself a quick map of the path we would take, what lies where etc. It was helpful. Infact WikiMapia should be even more helpful now that I have made a few edits to that area.

So in case you haven’t been there yet, this post should gve you a few ideas on what to look out for and how you can plan your day.

Now first thing, people don’t realize it, but that area is pretty big up there if you are curious enough and explore in all directions. I personally like trekking under a hot sun but the day we went was a pretty rainy/windy day and it was over all quite lovely. You’ll almost certainly encounter peacocks up there. Yea, peacocks! That’s right. Right in the middle of Pune city. The place up there is not as devoid of trees as the images on WikiMapia would have you believe. As of the writing of this post, the images are very old. Atleast in the monsoons when I went, the place is pretty much a “young forest”. And we were warned to watch out for “other” animals (probably an exaggeration).

Right, so there are multiple places where you can get onto the hills from. You can look around on the map for entry points, but remember that new buildings may have come up in the area from which you plan to get onto the hills from.

We decided to take the route to the hills from MIT college. Just get to MIT Engineering college, get to their play ground, and take the path that leads off it to the nearby resedential area and from there look for a path that seems to go into the hills. Turn around and take a few snaps of Pune city on your way up. You’ll get some nice shots there. That path will take you to ARAI (Automotive Research Association of India). It caused a huge outcry when it was being built a few years ago about spoiling the pristine beauty of Vetal Tekadi, the last refuge for nature lovers in Pune. However, it seems citizens and the Forest Department have woken up since and done a good job in keeping the place well protected from further “development”.

From ARAI, you can take a quick 15 minute short cut right up to the peak of Vetal Tekdi to “Vetal Baba Mandir”. Or you can do it our way and leave that for later. Instead take the path from ARAI that leads towards a small temple. It’s nice and quiet there. From here on, not too many people will be seen. One of the paths from that place goes towards the Law college hill area. Explore that area and come back. It’s nice and quiet and breezy up there. And you get a great view of the city from several places.

Then the other path from the temple will send you towards Pashan quarry – ugly gashes in the mountain from which stone has been mined for many years to build Pune city. Check out the pics. Along the same path, a TV tower can be seen. We went upto that. And from there we saw another one and headed towards it along some nice rocky terrain and got nice views of the city.

We then turned back and headed for the quarry, and then towards Vetal Baba Mandir, the highest point in this area. The temple is the only place around here where you’ll get water. No food is available around here. We had the brilliant idea of bringing along several packs of wafers, biscuits, bread and butter…..mmmm good stuff. Nothing like trash food and the peace of nature. A rather rickety watch tower is also present right beside Vetal Baba Mandir from which you can get some amazing bird’s eye views in all directions. Don’t miss that, but very careful climbing the thing.

Anyway, a lot of people come to Vetal Tekdi and do what we had done so far and go back down to ARAI and then to MIT and back to civilization. But here is the cool bit, we didn’t do that. It is actually possible to crossover to Chandni Chowk along the hills moving roughly parallel to Paud road. So make sure you have a good idea of what the general geography of the area is (Google Maps to the rescue) and take the path from from Vetal Tekdi towards the Chandni chowk area along the hills. Now that path isn’t really much of a “path”, but if you move in the right direction, you should be ok. Be warned, in the monsoons, that path is virtually non-existant. And there is a good chance that you’ll feel you are lost and totally cutoff from civilization in some places. You have to be the adventurous kind to do this.

Well so we took that…”path”. Rocky. Knee high grass. Path…what path? And kept moving along it expecting to finally reach Chandni Chowk or Pashan lake. But unfortunately, we had started out a little late. It was evening and it was getting darker by the minute. And being where we were after sun down would have been *real bad* trouble. Dhruv, who had been with me since the beginning was now starting to get jumpy and we finally realized Chandni chowk or the lake were too far away for us to reach now, we needed to get to civilization and we needed to get there fast. We started moving faster hoping to get to a place where we would get a choice to turn towards the city…but it never came. Finally we just left the path we had been following and turned towards the city going through dense bushes and rather rocky terrain and finally managed to reach the city at some slum area near Vanaz. Another 20 minutes or so and it would have been too dark to move through that area.

Back in good, old polluted Pune, we took a rickshaw back to the fork from Paud road towards MIT and landed at Durga’s. You must go there. Amazing cold coffee – “Rs.8 here. Rs.80 at Barista.” And not to forget their heavenly Anda Bhurjee (scrambled eggs).

So that’s how we did it. Perhaps next time I go there, I’ll start a little early and vist Pashan lake and have dinner at some place in Chandni Chowk. That would be the complete journey.

Oh and by the way, Vetal Tekdi isn’t the safest place to be in. It’s pretty much deserted. There have been “incidents” in the past. Go with a few friends. But it’s a different thing going alone(not recommended!) or with a single chum.

Please do keep the Tekdi free of litter. All poly bags and wrappers into your pockets/backpack please. I wish we had a digicam for the photos but a 2MP phone camera (Dhruv’s Sony Ericsson W830i) was all we had for the pictures seen here.


Firefox 2.0.0.7 released

September 19, 2007

Firefox 2.0.0.7 is out. It fixes a security flaw in dealing with QuickTime files.

Go on, update.