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.