Friday, August 29, 2008

Myth: Java widely used in the browser

Yes I aspire to be a MythBuster, don't we all? For a while now there has been some concern over Apple's apparent lack of love for Java. Lately the debate has shifted over to the iPhone and the Java blogosphere is doing its best to send a message to Apple. While I am far from a supporter of the policies and practices of Apple, I do think they are right in determining Java as legacy or an anomaly on the web of 2008.

A sniffing bot
It turns out it's hard to find concrete evidence of how widespread the use of Java client technology is on the internet. What we can do however, is simulate a web user, randomly browsing around and taking note of how often we bump into Java.
The first issue is, how can we come up with truly random URL's? Three different approaches comes to mind:

  1. Use some existing randomizer service

  2. Methodically run through IP ranges

  3. Screen scrape Google results

I actually implemented all 3. Of those both item 2 and 3 potentially raises some ethical questions, consistent scanning of remote systems can be considered a hostile activity as can web scraping. Thus the one presented here uses the 1'st approach only and is quite slow due to the fact that the random function of the site I am using seems to be bound by timestamp data (probably works by hashing the hh:mm:ss and looking up an index in a table). For that reason, and out of politeness, I've inserted a 1 sec delay between each attempt.

The scent of Java
Due to Java's age, there are quite a few ways it can be embedded onto a page depending on both HTML standards and individual browsers. There the APPLET tag, there's the OBJECT tag and then there's the EMBED tag. This should also include the recent iteration of Java client technology, namely JavaFX, since they appear to be reusing the APPLET tag for this - odd actually, considering W3C/HTML4.x deprecated this tag 9 years ago now.

Apart from these tags, JavaScript and frames can further hide the fact that Java technology is being used. This is not very common from what I've experienced though, much more common with Flex and especially Silverlight. Also we need to take into consideration Java Web Start, we do this by capturing links which points at *.jnlp files.

Implementation
Was pretty trivial, thanks to Java Swing's old but readily at hand HTMLEditorKit. The hardest part was coming up with a simple yet functional query language as I did not want to hardwire these rules nor depend on any 3'rd part library. The essence of the markup matching is modeled by an enum (I love Java enum's) and it looks like this:


enum TagMatch{
   
JAVA(// Most Java applets exist inside an APPLET tag
        Tag.create(HTML.Tag.APPLET, Attr.create(HTML.Attribute.CODE)),
        
// Java Web Start will be anchors ending in .jnlp
        Tag.create(HTML.Tag.A, Attr.create(HTML.Attribute.HREF, ".*\\.jnlp$")),
        
// OBJECT and EMBED tags pass in class or jar file
        Tag.create(HTML.Tag.PARAM, Attr.create(HTML.Attribute.VALUE, ".*\\.(class|jar)$"))
   
);
    
   
private List<Tag> tagMatches = new ArrayList<Tag>();

   
TagMatch(Tag... tagVararg){
       
tagMatches = Arrays.asList(tagVararg);
   
}

   
public List<Tag> getTagMatches(){
       
return tagMatches;
   
}
}


If you want to take a look at the whole source file, it's available righ here.

Enough with the talk
The following is the result of scanning 1.000 random sites:


Found 7 sites matching JAVA
+--[www.gailzavala.com/]
+--[www.nationalhealthcouncil.org/]
+--[web2c.com]
+--[armadaweb.com/Anime/Sailor/]
+--[www.gloverpainting.com]
+--[www.theschrodts.com]
+--[members.shaw.ca/micheil/burns/burns.htm]



Well well, 7 sites out of 1000 were identified as using Java on the client tier. I have of course run it a number of times, each resulting in roughly the same numbers somewhere between 5 and 10. This leaves me to conclude that the amount of sites using Java is less than 1%. And how about those that do? If you take a look at some of the links, at least half of them are webcam viewers, scrollers and counters reminiscent of the 90's.

Conclusion
Can't say I was surprised by the result. I am aware of a few things that relies on Java (home banking comes to mind) but then again, I also know of minority sites that use ActiveX. So I still think we can not slam Apple for this one. Certainly iPhone users would be missing Flash much more than Java. Of course, let's hope the new JavaFX stuff and the forthcoming update 10 will pan the way for a renascence.

Update:
People don't seem to like this entry very much. I'm not sure whether its because I am speaking negative about Java in the browser or if I simply didn't convey the message good enough. So to rephrase, this is a simple test to show that Java applets and web start applications are in such low use on websites that to most people (and by inference browser vendors) not having support for these doesn't matter much. Contrast this to the results I get when running another test, this time searching 1000 random sites for for Flash/Flex usage (tags with a SRC attribute containing ".swf"). Such a query results in the following matches:


Found 179 sites matching FLASH
+--[www.countrybumpkin.com.au/]
+--[www.chrissmithphoto.com]
+--[www.bostonbw.com]
+--[www.lipseylipsey.com]
+--[www.zewa.com]
+--[www.webguide.com/attractions.html]
+--[www.socaldelivery.com]
+--[www.lincolnspeedway.com]
+--[www.redcliffslodge.com]
+--[www.baldwin-school.org/]
+--[www.bdainc.com]
+--[www.hydraulicpumps.co.uk/]
+--[www.mainstreetcottonshop.com]
+--[www.yellowstonevacations.com]
+--[www.acmotorcars.com]
+--[www.deadwooddicks.com]
+--[www.judycarter.com]
+--[biz.yahoo.com/n/l/s/sun.html]
+--[www.siasat.com]
+--[www.jackand.co.jp/]
+--[www.meritax.com]
+--[www.westpasco.com]
+--[www.calpers-governance.org/]
+--[www.paradiseranch.com]
+--[www.tamilnaduwomen.org/]
+--[www.dynamitedetail.com]
+--[sportsillustrated.cnn.com/basketball/ncaa/men/teams/oregon/]
+--[www.glenfir.com]
+--[www.marquette.org/]
+--[www.uwwsports.com/index.asp?path=football]
+--[www.sfballoonguy.com]
+--[www.alliedmodular.com]
+--[www.helenelliott.com]
+--[www.nationwidemortgage.com.au/]
+--[www.admissions.umich.edu/]
+--[www.globalcredit.com]
+--[www.godinos.com]
+--[www.leonidas-chocolate.com]
+--[www.01-flash-web-templates.com]
+--[www.gwmcnamara.com]
+--[www.HiDoctor.com]
+--[www.metromayors.org/]
+--[www.vigorita.com]
+--[www.goforth.org/]
+--[www.reitdesign.com]
+--[www.brentlmiller.com]
+--[www.abingdon.com]
+--[www.ravenwoodgolf.com]
+--[www.goldner.com]
+--[www.sarasota.k12.fl.us/brookside/]
+--[www.craigsmithrv.com]
+--[www.labelexpress.com.au/]
+--[www.bagsoflove.co.uk/]
+--[www.var-provence.com/web_anglais/]
+--[www.santafe.cc.fl.us/]
+--[www.terrybryant.com]
+--[www.philanthropy.iupui.edu]
+--[www.kkla.com]
+--[www.iconicimaging.co.uk/]
+--[www.christielodge.com]
+--[www.waynegoodwin.org/]
+--[www.livingdesert.org/]
+--[www.scblues.com]
+--[www.skippinggirl.com]
+--[www.thebusinessgarden.co.uk/]
+--[www.armbrusterrealty.com]
+--[www.butterfly-kisses.com]
+--[www.acceptancefinancial.com]
+--[www.nvhomes.com]
+--[www.gerlinglaw.com]
+--[www.aweuk.com]
+--[www.uintagolf.com]
+--[www.lawinc.com]
+--[www.neteffects.com]
+--[www.coe.ufl.edu/]
+--[www.key2holidays.co.uk/]
+--[www.sachem.k12.ny.us/]
+--[asia.weather.yahoo.com/asia/China/]
+--[www.ecofurn.com.au/]
+--[www.breckenridgeskishop.com]
+--[www.camroadproperties.com]
+--[www.saassociates.com]
+--[www.cabrillo-inn.com]
+--[www.wwf.org.nz/]
+--[www.kenilworthinn.com]
+--[www.marinedivers.com]
+--[wagner.rivals.com]
+--[www.kanales.gr/]
+--[www.tourinfo.ru]
+--[www.krischs.com]
+--[www.visitlaportecounty.com]
+--[www.roninyachtcharters.com]
+--[www.utp.ac.pa/]
+--[www.colmet.com]
+--[www.rolltidebama.com]
+--[www.automotivecad.co.uk/]
+--[www.titancomics.com]
+--[www.breakfastclub80.com]
+--[www.arowanaclub.com]
+--[www.parachuteschool.com]
+--[www.kraft.com.au/]
+--[www.insuranceoffice.com]
+--[www.sbpolo.com]
+--[www.jlg.com/jlg/products/product-center.html]
+--[www.whmis.net/]
+--[www.theharleystreetclinic.com]
+--[www.rimatravel.co.uk/]
+--[www.uppercaperealty.com]
+--[www.cranecare.ltd.uk/]
+--[www.hostingpartners.co.uk/]
+--[www.jawfixer.com]
+--[www.telemoneyworld.com]
+--[www.minaret.vic.edu.au]
+--[www.houstontexaslaw.com]
+--[www.noisepop.com/2003/]
+--[www.crosswind.ms/]
+--[www.sweethomestexas.com]
+--[www.kahaku.go.jp/]
+--[www.keyualcohol.com]
+--[www.sdb.com]
+--[www.fgcswim.org/]
+--[www.quesnelcurlingclub.com]
+--[www.eggsolutions.ca/]
+--[www.msmedia.com.au]
+--[www.revesbypress.com.au/]
+--[www.strategicevents.com]
+--[www.anabenitez.com]
+--[www.ldai.com]
+--[www.c21capital.ca/]
+--[www.olympic.si/]
+--[www.mma.org.my/]
+--[www.markspencer.com]
+--[www.tdfund.com]
+--[www.residence-hotel.com]
+--[www.loanguy.com]
+--[www.middletonmann.freeserve.co.uk/]
+--[www.dallashomesales.com]
+--[www.firstcolorado.com]
+--[www.predatorsoftheheart.com]
+--[www.adtechintl.com]
+--[www.bleibtreu.com]
+--[www.kurt-darla.com]
+--[www.dreamkitchens.com]
+--[www.artsaloft.com]
+--[www.Theoakridgeschool.org/]
+--[www.maharashtratourism.gov.in/]
+--[www.lampson.com]
+--[www.token.com.tw/]
+--[www.panoptic-online.com]
+--[www.cbpacific.com]
+--[www.stricklandchevrolet.com]
+--[www.jamesnewhouselaw.com]
+--[www.vlada.hr/]
+--[www.calc.com]
+--[www.mustakbil.com]
+--[southwestutahfilm.com]
+--[www.sackville.com]
+--[www.bonbonniere.nl/]
+--[www.lizzydesign.com]
+--[www.ambientjobs.com]
+--[www.nola.com/lsu/]
+--[www.greenbergchiropractic.com]
+--[www.donsphoto.com]
+--[sports.espn.go.com/ncf/clubhouse?teamId=324]
+--[www.dangleterrehotel.com]
+--[www.mcsellshomes.com]
+--[www.driversity.com]
+--[www.gbm.net/]
+--[www.ingraham.net]
+--[www.bib-aveiro.rcts.pt]
+--[www.carlos-restaurant.com]
+--[sanbruno.ca.gov/]
+--[www.tufts.edu/as/astronomy/]
+--[www.ci.superior.wi.us/]
+--[www.mitchellrepublic.com]
+--[www.utcc.ac.th/amsar/about/document24.htm]
+--[www.nonchalance.org/]
+--[www.pelicancruiser.com]
+--[www.rayhana.com]



With 179 vs. 7 hits, obviously one must conclude that, at present time at least, having Flash support in the browser matters a great deal more to an average user than having Java support does.

Post a Comment