Tuesday, July 15, 2008

How To Install, Compile, Run Java On iPhone

iPhone doesn't natively support Java / J2ME. However as a J2ME developer there are two good ways to develop iPhone applications using Java / J2ME. Read below for details and also to know how you can upload, compile and run Java applications on iPhone.


alcheMo-for-iPhone - Automated J2ME to iPhone porting solution

alcheMo for iPhone contains translator to convert J2ME application source code to equivalent C++ source code for iPhone.

No manual adjustments to the translated source code is required. Compiled using the standard Xcode toolchain and linked with alcheMo's optimized run-time library, a native iPhone application is produced.

alcheMo for iPhone is capable of converting J2ME applications utilizing an extensive subset of Java ME CLDC 1.1 and MIDP 2.0 (including touch screen support) and supports several JSR extension APIs including the JSR-256 mobile sensor API. This automatic translation process is instantaneous, repeatable and doesn't require iPhone specific experience.

Garbage collection and automatic memory management is one of the strengths of the J2ME environment. Unlike on Macintosh OS X, Objective C on iPhone does not support garbage collection. By incorporating an advanced garbage collector, alcheMo eliminates the need for manual memory management. Whole classes of common programming errors such as dangling pointers are thus prevented.

The initial version of alcheMo for iPhone is optimized for mobile games.

The bad news is that their beta program has closed on April 24th, while they are preparing for commercial release. alcheMo for iPhone has backing from Sun Microsystem.

BTW: During Java One 2008, Sun officials repeatedly mentioned that they successfully ran Java on iPhone but are thwarted only by Apple's licensing restrictions in publicly announcing it. alcheMo circumvents Apple's licensing restrictions with their language translator.

Using Java on Unlocked & Jailbraked iPhone with Installer

Note: The legality of the procedure below is dubious. IANAL.

First you need to unlock and jailbrake you iPhone. You can use the windows user interface for ZiPhone to jailbreak, unlock and activate any verion of iPhone.

Then you need to have the installer app on iPhone. Installer.app is a UIKit based package manager for the iPhone. It works by downloading packages over WiFi (wireless networking) or EDGE. It supports installing, updating and uninstalling applications from multiple sources.

winpwn can simplify the above steps for you.

Now go to Installer and install Mobile Terminal and Cydia Installer. Restart iPhone.

Run Cydia Installer and go to Java section and select iPhone/Java which will install the virtual machine, libraries etc. Then install Jikes (java compiler). Now restart iPhone again.

That's it, you are done.

How to load, compile & run Java applications on iPhone

First install Java on iPhone following instructions in the section above before reading this.

You can upload Java files to iPhone using iPhone Browser.
Run Terminal (installed above) and use java (jikes) compiler to compiler your program. For example:
jikes -cp /usr/lib/rt.jar MyFirstJavaProgramForIPhone.java

You can run the class file as usual:
java MyFirstJavaProgramForIPhone

Java on iPhone - Concluding thoughts

The second method (using jailbraked iPhone) suffers from three major problems.
1. To use your Java applications, your user will also have to jailbrake their iPhone. As such its usage will be limited to highly technical people who are not afraid of tinkering with their costly iPhone and potentially even risk damaging it permanently!

2. While it may be fine for experimenting, the legality is dubious. You may run into problem with Apple for selling or even distributing such applications.

3. The jailbraked versions of iPhone may not be compatible with future firmware updates, and Apple will try their best to disable them at every opportunity and had done so in the past.

All of the above makes method 2 unsuitable for commercial use.

Commercial J2ME developers have to wait for commercial release of alcheMo-for-iPhone. Innaworks is well known for porting standards compliant J2ME to BREW mobile platform. I expect their solution to be ready in 2-3 months time. If you do not have the time then download Apple's iPhone SDK and start coding in Objective C.
BTW: Make sure you read the iPhone SDK agreement carefully before you invest huge sums in iPhone development.

Sun Releases Java Composite Application Platform Suite (Java Caps) 6

The Java Composite Application Platform Suite is a collection of middleware software suites using service-oriented architecture for business integration (SOA/BI). Java CAPS is a standard based open source platform for developing software infrastructures using SOA. It is one of the first open-source SOA platforms which have been created using Open ESB (The Enterprise Service Bus) community.

Java CAPS provides the tools you need for designing, deploying, and managing platform-independent vendor-neutral composite applications.

Java CAPS 6 retains most of the feature set of previous Java CAPS releases, originating in the ICAN and eGate suites from SeeBeyond, and provides further flexibility through standardization. The Java Business Integration (JBI) standard is a vendor-neutral specification that defines a "container of containers": Any JBI-compliant application is automatically interoperable with Java CAPS applications. Design-time tooling is standardized and upgraded to NetBeans IDE 6.1. Runtime functions are standardized to Sun Java System Application Server 9.1.

Java CAPS provides adapters to read and write data in the native format of specific databases or business systems, such as Oracle, Sybase, HL7, SWIFT, HIPAA, SAP, PeopleSoft, and dozens of others. In addition to adapters for data modeling and representation, Java CAPS also provides collaborations and engines for data transformation, and an implementation of the Java Messaging Service (JMS) for data queuing.

Note: A service-oriented architecture (SOA) defines a framework for creating, exposing, and invoking services that are loosely coupled and interoperable, and orchestrating them with business logic to achieve a particular objective.

The changes in this version are:
1. New GUI for design work. Uses NetBeans 6 plug-ins for familiarity, maintainability, compatibility.

2. Tailored for Sun Java Application Server 9.1

3. Support for JBI components (as NetBeans plug-ins):

  • BDRU = BiDirectional ReUse (JBI Bridge)
  • Sun Java Message Server
  • Service Engines (SEs) for: Java EE, BPEL
  • Binding Components (BCs) for: HTTP/SOAP
  • CASA Editor (Composite Application Service Assemblies)
  • eView / Mural

Where can you use Java CAPS?

  • Data integration applications
  • SOA / ESB Applications
  • Composite Application Initiatives - Combine new or existing business applications to create composite applications.

Some benefits of using Java Caps 6:

  • Its open source which reduces risks and ends vendor lock in
  • Offers a common design and monitoring environment for integration of components within suite
  • Provides a secure and scalable platform for supporting SOA

Give it a try. I am sure you will like it.

Free Java Certification Exam Retake Promotion

To commemorate Sun's awarding over half million certifications, Sun will allow you to re-take the exam one additional time, should you need it, for free if you place your order by June 20 2008. If you are not sure about your chances in the very first time, this is a golden opportunity for you. Here's how you can avail this opportunity.

First you must use Priority Code WW48CX1 when you place your order for your chosen Sun certification.

Note: The following new certifications are available

  • Sun Certified Web Component Developer (SCWCD) - Updated to Java EE5
  • Sun Certified Enterprise Architect (SCEA) - Updated to Java EE5
  • Sun Certified Systems Administrator for Sun Cluster 3.2 Software
  • Sun Certified JCAPS Integrator

After you purchased your exam voucher, you should then schedule your exam date, time and location here.

If you do not pass the exam, simply contact the Authorized Prometric Testing Center like you did before and provide your original certification exam voucher number.
Note:

  1. You must allow 72 hours after taking your initial exam before scheduling the free retake exam.
  2. Please also be aware that per Sun certification guidelines you must wait at least 14 days before you may retake any exam.
  3. There is no need to contact Sun to schedule your retake exam.

5 Free Java Exams From Sun

Sun offers 5 free proficiency assessment examinations. Read below for details and how you can take them.

Sun Certified Associate for the Java Platform, Standard Edition, Exam Version 1.0
Exam Objectives:
  • Fundamental Object-Oriented Concepts
  • UML Representation of Object-Oriented Concepts
  • Java Implementation of Object-Oriented Concepts
  • Algorithm Design and Implementation
  • Java Development Fundamentals
  • Java Platforms and Integration Technologies
  • Client Technologies
  • Server Technologies
Sun Certified Programmer for the Java 2 Platform, Standard Edition 5.0
Exam Objectives:
  • Declarations, Initialization and Scoping
  • Flow Control
  • API Contents
  • Concurrency
  • OO Concepts
  • Collections / Generics
  • Fundamentals
Sun Certified Business Component Developer for the Java Platform, Enterprise Edition 5
Exam Objectives:
  • EJB 3.0 Overview
  • General EJB 3.0 Enterprise Bean Knowledge
  • EJB 3.0 Session Bean Component Contract and Life Cycle
  • EJB 3.0 Message-Driven Bean Component Contract
  • Java Persistence API Entities
  • Java Persistence Entity Operations
  • Persistence Units and Persistence Contexts
  • Java Persistence Query Language
  • Transactions
  • Exceptions
  • Security Management
Sun Certified Mobile Application Developer for the Java 2 Platform, Micro Edition, Version 1.0
Exam Objectives:
  • JTWI (JSR 185) and Overview of JTWI-Compliant Wireless Applications
  • CLDL 1.0 and 1.1
  • Security (Both CLDC and MIDP)
  • Networking
  • Application Model, Delivery, Lifecycle, and Provisioning
  • MIDP Persistent Storage
  • Push Registry
  • MIDP User Interface (UI) API
Sun Certified Developer for Java Web Services
Exam Objectives:
  • XML Web Service Standards
  • SOAP 1.1 Web Service Standards
  • Describing and Publishing (WSDL and UDDI)
  • JAX-RPC
  • SOAP and XML Processing APIs (JAXP, JAXB, and SAAJ)
  • JAXR
  • J2EE Web Services
  • Security
  • Developing Web Services
  • General Design and Architecture
  • Endpoint Design and Architecture

These pre-assessment exams will also help you to determine which Java certification course is best suited to your current level of skill and knowledge.

You can take the exams here.

Check for a string to be in English using Java

This is useful especially if you are insanely bugged by the smart testers who love international characters being filled at the places where it is not required.

Here is the simple checking code. As always, if you have something better to share, please use comments.


public static boolean canEncode(String s, String cs)
{
try
{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
Writer w = new OutputStreamWriter(baos, cs);
w.write(s);
w.close();
String t = baos.toString(cs);
return s.equals(t);
}
catch(Exception e)
{
return false;
}
}

21 Laws of Computer Programming

As any experienced computer programmer knows, there are unwritten laws that govern software development. However there are no penalties for breaking these laws; rather, there is often a reward. Following are 21 Laws of Computer Programming:

  1. Any given program, once deployed, is already obsolete.
  2. It is easier to change the specification to fit the program than vice versa.
  3. If a program is useful, it will have to be changed.
  4. If a program is useless, it will have to be documented.
  5. Only ten percent of the code in any given program will ever execute.
  6. Software expands to consume all available resources.
  7. Any non-trivial program contains at least one error.
  8. The probability of a flawless demo is inversely proportional to the number of people watching, raised to the power of the amount of money involved.
  9. Not until a program has been in production for at least six months will its most harmful error be discovered.
  10. Undetectable errors are infinite in variety, in contrast to detectable errors, which by definition are limited.
  11. The effort required to correct an error increases exponentially with time.
  12. Program complexity grows until it exceeds the capabilities of the programmer who must maintain it.
  13. Any code of your own that you haven't looked at in months might as well have been written by someone else.
  14. Inside every small program is a large program struggling to get out.
  15. The sooner you start coding a program, the longer it will take.
  16. A carelessly planned project takes three times longer to complete than expected; a carefully planned project takes only twice as long.
  17. Adding programmers to a late project makes it later.
  18. A program is never less than 90% complete, and never more than 95% complete.
  19. If you automate a mess, you get an automated mess.
  20. Build a program that even a fool can use, and only a fool will want to use it.
  21. Users truly don't know what they want in a program until they use it.

Is Google Heading Down the Yahoo! Path?

by Josh Catone


This week Google made the fourth announcement in the past 12 months that has made me question whether the company is beginning to lose focus. Google built itself to be the 33rd biggest company in the world (by market value) — the 10th largest in the US — based almost exclusively on one thing: its dominance of the online advertising market, specifically the search advertising market. But recent forays in areas outside of search and into content production and even areas notoriously difficult to monetize have has made me begin to wonder if Google is heading down the “kitchen sink” path that has been so disastrous for Yahoo!

It began last year with Google News. In August of 2007, Google News announced that it would begin hosting content from wire services. To be fair, this was mainly a response to legal troubles the site ran into for linking to wire content with excerpts. But even so, it was a shift from a service that nicely paralelled their core search business — one which indexed and linked to content, like search — to one that involved the publication of original content.

Yahoo!’s News site has been one of the major successes for the company, long the web leader in the news and media category according to market analytics firm Hitwise. Google’s move could be seen as a way to keep ad dollars in house (and thus fit in with their core offering), but Google does not display ads on its news site.

Next, in December of last year Google announced the Knol Project. Think of Knol, which is still in private beta, as Wikipedia with ad revenue sharing. Even with the advertising component, Knol is still a foray into content production rather than content indexing (one that the Guardian’s Jack Schofield called, “an attack on the media industry in general.”)

Why didn’t Google just invest in the non-profit Wikimedia Foundation’s Wikipedia project the way it has in the Mozilla Foundation’s Firefox web browser? Certainly, Knol could be an advertising play and could produce content that could be used as the basis for a semantic database to enhance their search engine, but it is also still a content play. And that’s dangerous waters. History has shown that Yahoo! was wrong to try and turn itself into a media company, so it is baffling to see Google make moves in that direction.


In the last couple of weeks things are really starting to come unglued. First, at the end of June the New York Times reported that Google had struck a deal with the creator of Family Guy to create original cartoon content to be distributed via the Adsense network as video ads. I like Family guy as much as the next guy, and being that I live a few blocks from where Seth MacFarlane went to college, I get a kick out of all the local references in the show, but this one is just a little too Yahoo!-like.

It was no secret that during Terry Semel’s reign as Yahoo! CEO he wanted to push the company more toward the media end of its business and away from search (he even commuted from LA). It hasn’t worked for Yahoo!, so why is Google trying it?

That’s the same sentiment that comes to mind with this week’s announcement: Lively. Google released a new 3D virtual world earlier this week called Lively. Yes, it started as a “20% project,” but now it has Google’s official blessing.


Second Life, the most well-known and perhaps largest non-game virtual world, has struggled to sell itself to businesses, so why is Google trying it? Second Life’s traffic has basically plateaued, so Lively seems like a strange application for Google to be launching. Is it and the rest indicative of a growing lack of focus at the company?

Most of Google’s forays outside of their core search business — YouTube, the Android phone platform, the Google Apps suite, etc. — can be looked at as somehow corollary to their other core business of web advertising or as strategic attempts to weaken key competitors. (Though YouTube is proving very difficult to monetize.)

But could Google be spreading itself too thin the way Yahoo! did over the past decade? Is Google starting to eat the peanut butter? What do you think: is the search giant losing focus of their core business?

How slow is your website?


by Matt Mickiewicz

Broadband connections mean nothing for users if your site is slow because it’s poorly coded or thought out.

YSlow, a new plug-in that integrates with Firebug , has just been released by Yahoo’s Expectional Performance Team to help you pinpoint and fix specific trouble spots.

YSlow evaluates 13 different performance factors and provides a letter grade to each. If for any reason you fail to score a straighth ‘A’, YSlow will provide additional detail to help you solve the problem.

Let’s see how sitepoint.com did:

YSlow in Firebug

Overall 64/100 (or a “D”) largely because we don’t use a CDN (Content Delivery Network such as Akamai) nor Entity Tags.

Aside from rating performance factors, YSlow provides useful stats on the loading size of your website, for both brand-new visitors as well as return users who might have portions of your site still in their cache. Here’s how it looks:

Components Report in YSlow