Get Started With HTML5 Webinar

The webinar today was a huge success. We had about 300 attendees. There were many excellent questions.

You can download the presentation and sample code from this link.

Links to useful resources:

  1. Modernizr library.
  2. How good is your browser’s HTML5 support?
  3. So many specs, where do they all come from?
  4. HTML5 Training.

No Comments

Using the WASService.exe Command

The WASService.exe command allows you to setup a Windows service for a WebSphere server. The command has its own idiosyncratic behavior. Best way to learn about the program is through actual examples.

Removing a Service

Removing a  service seems pretty easy:

wasservice -remove SERVICE_NAME

What this command considers as service name is not same as Windows. A service has two names in Windows. A display name and service name. You can find out more about these names by running this Windows command

sc query state= all

Note: Notice the space after “state=”. Without the space, the command will fail.

WebSphere service names usually contain “IBM”. So, you can view all registered WebSphere services by running this command:

sc query state= all  | findstr IBM

If Windows shows the service name (not the display name) as “IBMWAS70Service – myNode01”, then you need to use myNode01 as the service name for the wasservice command. That is, use the name after “-“. For example:

wasservice  -remove  myNode01

This is effectively same as running the command:

sc  delete "IBMWAS70Service – myNode01"

Adding a Service

The example below will show you how to add a service that has administrative security enabled.

wasservice -add myNode01 -serverName server1
  -profilePath C:\WebSphere70\profiles\AppSrv01
  -wasHome C:\WebSphere70
  -logRoot C:\WebSphere70\profiles\AppSrv01\logs\server1
  -startType automatic
  -stopArgs "-username wasadmin -password waspass"

This will create a Windows service called “IBMWAS70Service – myNode01” for WAS7 and “IBMWAS80Service – myNode01” in WAS8.

Note: that the entire stopArgs argument has to be within double quotes.

2 Comments

Long Running Work in Same Thread

By default, in Android, a single thread is used to run every application component, such as Activity and Service. If you perform a long running task from an event handler, messages to all other components will be delayed. Generally speaking, spawning a separate thread for long running work is recommended. At the same time, you do not always need the complication of a separate thread. In this article below, we will show you how to use the Handler framework to carry out a long work in small chunks using the solitary main thread of the application. You can even show a progress dialog to keep the user notified.

image

Basics of the Handler Framework

In Android, you can use an android.os.Handler object to post a message in the event queue of the thread where the handler is created. Keep in mind, all UI events are processed in the main thread of the application. If you create a handler in that thread then all messages for that handler will be mixed with the UI events in the queue.

The Handler class has many sendXXX() methods to queue a message. We will use the very basic sendEmptyMessage(int what) method.

When a message arrives for a Handler, the handleMessage(Message msg) method is called.

Getting Started

In your activity that will do the long running work, add these member variables.

ProgressDialog mProgressDialog;
int mProgressAmount = 0;

Create another member variable for the Handler.

final Handler mHandler = new Handler() {
	public void handleMessage(Message msg) {
		try {
			Log.v("Handler", "Progress: " + mProgressAmount);
			Thread.sleep(500);
		} catch (Exception e) {
		}
		mProgressAmount += 10;
		if (mProgressAmount < 100) {
			sendEmptyMessage(0);
		} else {
			mProgressDialog.dismiss();
		}
	}
};

The handleMessage method performs the long running operation in small chunks. Work is simulated here by the Thread.sleep() method. If further work is needed, we send another message for the handler. If work is done, we dismiss the progress dialog.

Finally, from the on click event handler of a button or some other event handler, we kick off the work.

public void onClick(View arg0) {
	mProgressAmount = 0;
	mProgressDialog = ProgressDialog.show(this, "", "Loading. Please wait...", true);

	mHandler.sendEmptyMessage(0);
}

Showing Progress Amount

image

We can easily use a horizontal progress bar. Change the way the progress bar dialog is created.

public void onClick(View arg0) {
	mProgressAmount = 0;
	
	mProgressDialog = new ProgressDialog(this);
	mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
	mProgressDialog.setMessage("Loading. Please wait...");
	mProgressDialog.show();
	
	mHandler.sendEmptyMessage(0);
}

In the handler, increment the progress amount.

mProgressAmount += 10;
mProgressDialog.incrementProgressBy(10);

Analysis

Here we see a simple technique to break up a long running work in small pieces and doing all the work in the main thread of the application. The progress bar dialog prevents any interaction with the activity while the work is in progress.

If, in the middle of the work, user clicks the back button, the progress dialog will be dismissed. But the work will continue. User is able to interact with the Activity at this point. This can lead to undesirable behavior. To prevent this from happening, make the progress dialog non-cancelable.

mProgressDialog.setCancelable(false);

No Comments

Custom Toast with Border

In Android, a Toast is a great way to show popup notification to users. It can be used by a background service, which otherwise has no visible user interface. By default, a toast simply shows a text message. In this tutorial, we will show you how to use a layout resource to display custom content. We will also show you how to provide a custom border to the view.

The tutorial assumes that you have a functional Eclipse based Android development system.

When done, the toast will look like this.

image

Create the Resources

We need three resource files.

  1. An image resource file. This image is shown in the left hand side of the toast.
  2. A shape resource file that will draw the rounded rectangle border around the toast.
  3. A layout resource file that defines the views for the toast.

First, create a small image file. Save it in the project as res/drawable/annie.png.

Next, in the res/drawable folder, create a new XML file called my_border.xml. Set the contents of the file as follows.

<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"> 
    <stroke android:width="4dp" android:color="#FFFFFFFF" /> 
    <padding android:left="7dp" android:top="7dp" 
            android:right="7dp" android:bottom="7dp" /> 
    <corners android:radius="4dp" /> 
</shape>

Next, in the res/layout folder, create a new layout file called my_toast.xml. Set its content as follows.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
	android:layout_width="wrap_content" 
	android:layout_height="wrap_content"
	android:background="@drawable/my_border">
<ImageView android:layout_width="wrap_content"
	android:layout_height="wrap_content" 
	android:src="@drawable/annie" />
<TextView android:layout_width="wrap_content"
	android:layout_height="wrap_content" 
	android:text="The image has been uploaded"
	android:layout_gravity="center_vertical" />
</LinearLayout>

Note, how the border shape is set for the root ViewGroup, the LinearLayout, using the background attribute.

Here is a screenshot of all three files.

image

Create and Show the Toast

The trick is to load the layout from the XML file and set the root view of the toast.

From an event handler of your activity, do the following.

Context context = getApplicationContext();
LayoutInflater inflater = getLayoutInflater();

View toastRoot = inflater.inflate(R.layout.my_toast, null);

Toast toast = new Toast(context);

toast.setView(toastRoot);
toast.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL,
		0, 0);
toast.show();

We are using a LayoutInflater to load the root view from the resource file. Then we are calling setView of the toast to set the root view.

8 Comments

Making Equal Width Buttons in Android

It is a common requirement to layout a bunch of buttons side by side. Making them of equal width is just plain good GUI design.

image

To achieve the effect above, first create a LinearLayout just for the buttons. The layout will contain three buttons.

<LinearLayout android:id="@+id/LinearLayout02" android:layout_height="wrap_content" 
  android:layout_width="fill_parent">
  <Button android:layout_height="wrap_content" android:text="Update" 
    android:layout_width="fill_parent" android:layout_weight="1"/>
  <Button android:layout_height="wrap_content" android:text="New" 
    android:layout_width="fill_parent" android:layout_weight="1"/>
  <Button android:layout_height="wrap_content" android:text="Delete" 
    android:layout_width="fill_parent" android:layout_weight="1"/>
</LinearLayout>

We took these steps to get the effect:

1. For the LinearLayout we set android:layout_width="fill_parent". This causes the layout view to take up the full width available from the device.

2. For each Button, we set android:layout_width="fill_parent" and android:layout_weight="1".

9 Comments

WebSphere Enterprise Service Bus 7.0 Courses Announced

We have posted course descriptions and outlines to support the latest version of WebSphere Enterprise Service Bus, v7.0.  These courses are targeted to developers or administrators that work with this version.  The programming course highlights the various integration patterns that can be implemented with the WebSphere ESB and the administration course focuses on creating production topologies that leverage the performance and scalability capabilities of the product.

WA1916 WebSphere Enterprise Service Bus (ESB) v7.0 Programming Using WebSphere Integration Developer

WA1912 WebSphere Enterprise Service Bus (ESB) v7.0 Administration

These courses are in addition to our already released courses on WebSphere Process Server v7.0.

WA1844 WebSphere Process Server 7.0 Programming Using WebSphere Integration Developer

WA1853 WebSphere Process Server v7.0 Administration

If you are using v6.2 of WebSphere Enterprise Service Bus you might also be interested in the following courses which are available now.

WA1797 WebSphere Enterprise Service Bus (ESB) 6.2 Programming Using WebSphere Integration Developer

WA1804 WebSphere Enterprise Service Bus (ESB) v6.2 Administration

No Comments

Seam, Java for Managers Courses Updated

Seam Course WA1627 Updated

Whether it is the fact that people are finally using the JBoss Enterprise Application Platform 5.0 version or that much of the Seam programming model was adopted into the Java EE 6 specifications we are seeing a recent increase in interest in Seam.  Seam provides a deep integration of technologies such as Asynchronous JavaScript and XML (AJAX), JavaServer Faces (JSF), Java Persistence (JPA), and Enterprise Java Beans (EJB 3.0).  The Seam framework also provides a simplification of linking application components together with a dependency injection mechanism even more advanced than the popular Spring framework.

Because of this recent increase in interest we have updated the setup of our Seam programming class to support the latest versions of Eclipse and JBoss that developers would be using.  There are useful tips about using these most recent versions provided with the hands on labs that accompany the course. 

 

WA1413 Java for Managers Updated

We have just released an update to our “Java for Managers” training.  This two day course covers a broad overview of many different Java technologies and other topics like various Java IDEs and frameworks.  The course also covers some of the latest developments in the Java landscape so you can stay up to date with the changes in the Java technologies developers are using in projects and know the latest information to make informed decisions about those technologies.  Since students attending this course will generally not be doing actual development there are many demonstrations presented by the instructor that will briefly show using various tools and technologies without getting lost trying to follow lab instructions.

No Comments

Will Java Be Around in Five Years?

Clearly as an employee of a company that makes a lot of it’s business on training and consulting for Java programming and technologies this is not a pleasant thought to entertain.  It also seems like a fairly somber topic for my first post to our company blog.  Unfortunately this is a question I’ve been asking myself over the past few years (as really anyone who works with technology should ask) and lately I’m a little more concerned about the possible answers and factors that allow you to arrive at those answers.

First, I think a little bit of history about why this has concerned me of late…

Back even before Sun was swallowed by Oracle I was commenting internally on a situation that was developing that I was somewhat concerned about.  The situation was a dispute between Sun and Apache around the efforts of Apache to create an open-source implementation of Java SE, Apache Harmony.

I won’t get into too many details but it basically came down to the fact that the Apache Harmony project was unable to get a copy of the “Java Compatibility Kit” or “JCK” which would be used to certify that the Apache Harmony implementation is fully compliant with the Java SE specification (a good description of the problem is available on Stephen Colebourne’s blog).  Sun was willing to provide Apache Harmony with a copy of the JCK but it’s license placed “field of use” restrictions on what users of Apache Harmony could use Harmony on.  Since the people at Apache are very serious about licensing and open source software they argued that Sun was basically violating the rules that they themselves set out for the Java Community Process (JCP) which stated that the lead of a JCP specification could not place any contractual restriction on the right of a licensee (in this case Harmony) to create or distribute independent implementations.

The entire issue Apache was correctly pointing out was that nobody was going to be able to create independent implementations of Java SE (and therefore just about anything Java) without accepting these limits that they would need to pass along to users of their implementation.

If it were just Apache that held this view it may not have had much impact because the JCP works with specifications by allowing members that are part of the various “Executive Committees” (currently Java ME and Java SE/EE) to vote on Java Specification Requests (JSRs) that are proposed to create Java specifications.  Since the JSR process is one of the things that makes the Java community so vibrant this is obviously an important process.

As this issue developed it was clear from the minutes of the JCP Executive Committees that the other EC members recognized this dispute was about more than just Sun v. Harmony and had broader implications.  In fact, it was pretty clear from the minutes that there was broad agreement with Apache from most EC members, including Oracle (pre takeover), that this dispute needed to be resolved and that Sun didn’t have many friends that were seeing it’s side. 

It had gotten so bad recently that on the recent Java EE 6 public review ballot, Apache actually voted no because it felt Sun was violating the agreements of the JCP and many other members of the Java SE/EE executive committee expressed concern about the issue, although only Apache voted no. 

In fact the US Department of Justice extended it’s period for reviewing proposed acquisitions for the Oracle acquisition of Sun apparently specifically to investigate the Java licensing issue.  Unfortunately it was not apparent publically that the issue was resolved or any closer to resolution before the merger completed.

This matters for the broader Java community because this issue will probably come to a head over Java SE 7.  Java SE 7 “features” are being developed in OpenJDK right now but there is no specification proposal.  OpenJDK is the “open source implementation of Java that we control” started by Sun and now Oracle.  Even though the argument could be made that OpenJDK is an “independent implementation” of Java SE it also allows Oracle to release the OpenJDK implementation as the official Java SE JSR implementation where they could reintroduce the restrictions on the compatibility kit.

Sun and now Oracle have not yet submitted any JSR for Java SE 7.  Based on the comments of many Java JCP board member companies on recent specifications like Java EE 6 I get the feeling that the Java SE 7 spec would actually be voted down if Oracle would not allow open source implementations to license the Java Compatibility Kit and therefore be “certified” without the restrictions.  This of course would make headlines nobody involved with Java would want. 

Now enter Google and Android…

The Android platform from Google is based on a subset of Apache Harmony recompiled into the “Dalvik” VM for mobile devices.  This provides support for Android applications to be written in Java but obviously does not go the route of Java ME (Mobile Edition) which is of course the “official way” Android could have done it.  This has resulted in Oracle suing Google in a case that could have the same implications for the Java community that Sun v. Microsoft did.

The unfortunate thing about the lawsuit is that according to some the Apache and Oracle camps may have been working recently to “finally certify Harmony with Oracle”.  Even though no resolution was made it was promising that this was still an active issue.  One has to wonder where the lawsuit puts the process of certifying Harmony.  What is interesting from the article link above is that Apache seemed to agree with Oracle that the actions taken by Google would threaten to fracture the Java community.

This would be unfortunate because mobile smartphones really have the promise to expand the reach of Java all over which was always the goal of Java but just now becoming the reality.

The Oracle v Google lawsuit itself is based around software patents and not directly the licensing issues of Harmony and Java SE.  I think this is more because Oracle feels that a lawsuit about patent infringement would be easier to try in court unlike the confusing maze of licensing issues from directly challenging Android using an unlicensed Harmony.

I won’t really comment much on the lawsuit itself because there are certainly lots of other opinions out there.  Some are touting it as the “final showdown” between software patents and open source.  Some feel that Oracle is simply trying to capitalize financially from acquiring Sun and Java.  Others are glad that Oracle is stepping up to defend Java.  James Gosling (creator of Java) also has some interesting thoughts although it seems like it is mostly “I could see this coming” when he was still working at Oracle before leaving recently.

I think I am somewhere in the middle.  I don’t think Google is totally faultless as it seems like they were just begging to get sued by the approach they took.  I also think that even if Oracle doesn’t get entirely what they want part of what they might have wanted to accomplish is to create uncertainty about the Android platform, which they certainly have done.

So finally, back to our original question, will Java be around in five years?…

After the Oracle v. Google lawsuit got me thinking more about this again some research caused some concerns and reassurances.

At first I was concerned with the fact that if you look at the summary of JCP JSRs by stage there are no JSRs in the early stages of proposal or early review.  Some research shows however that the number of JSRs has been declining for some time, probably due to a number of factors although the battle of Java licensing certainly has to be one of those factors.  Of course there did seem to be a steady-state of JSR work from 2004-2006 and since the Sun/Apache issue started 2005-2006 it could also be argued that it was part of the JSR decline.

It is clear that the JCP process itself is likely going to have some major changes.  There are notes in the May 2010 JCP EC minutes that the EC discussed the proposed future of the JCP process by Oracle although the discussion was a “private session” with no details except the general topic and the July 2010 minutes are not yet published.  Unfortunately I’m not sure that the Google lawsuit exactly bodes well for the possible future of what the JCP will be.

I’m also concerned that even though Java retains it’s spot as the most popular programming language there was significant downward movement since last July and Java only barely held on the top spot compared to C.  Certainly a headline of “Java is no longer the most popular language” is not the kind of headline that would help after the lawsuit and right about the time that JavaOne will convene for the first time under Oracle.

I think overall Java will be around in five years as too many companies, including Oracle itself, have too many products based on Java.  It is more just a question of what kind of shape it might be in.  The next few years will actually probably be on fire as the Java EE 6 specification is a great step forward in the simplification and power of Java much like Java EE 5 was.  We are also going to see many major vendors implementing Java EE 6 much faster than they did with Java EE 5 which will be good.

We will have to see if the statement “Oracle supports open source” is just lip service meant to buy time to retain complete ownership of Java.

I think this is something important to follow because it might throw a hiccup into the Java maturation process at exactly the time many companies are taking a second look at Java.  Hearing that there are “license disputes” that are preventing the Java specifications from moving forward would certainly throw some cold water on any plans to move to Java after previously deciding against it. 

Hopefully those reading this that may not have been aware of the issues and how there is an underlying thread among many of these developments have benefited from getting quickly up to speed.  I think there will hopefully be quite a bit of information about many of these issues at the JavaOne conference in mid-September.  Stay tuned here for what I think everyone will agree is hoped to be good news on this front after a summer of some troubling news.

 

Let’s Hope,

Stuart Smith

Java and Administration Lead

Web Age Solutions

 

Here is some useful information if you want more info:

Apache statement on the Sun/Apache dispute – http://www.apache.org/jcp/sunopenletter.html

History on the original Sun/Apache dispute (Stephen Colebourne’s blog) – http://www.jroller.com/scolebourne/entry/shedding_new_light_on_no

An article on the issue between Google Android and Oracle (pre-lawsuit) – http://www.theregister.co.uk/2010/06/09/harmony_android_oracle_apache/

JCP Executive Committee minutes – http://jcp.org/en/resources/EC_summaries

1 Comment

Oracle WebLogic Portal 10gR3 Programming Course Launched

We are proud to have released Oracle WebLogic Portal 10gR3 programming course. This 3 day course focuses primarily on the JSR 286 API. It also covers JSF portlet bridge based portlet development. Extensive hands on lab exercises accompany the lecture sessions. These labs are done using Oracle Enterprise Pack for Eclipse.

Links to the relevant pages:

  1. WA1922 WebLogic Portal 10.3 Programming Training
  2. Detailed outline

No Comments

HTML 5 Training Course Announced

Today, Web Age announced its HTML5 course. HTML5 is a major change to the way web pages will be designed from now on. You can expect much richer user experience and innovative web applications. Topics covered are:

Chapter 1. Introduction to HTML 5

Chapter 2. The Basics

Chapter 3. New Semantic Elements

Chapter 4. New User Input Options

Chapter 5. The Canvas

Chapter 6. Audio and Video

Chapter 7. Geolocation

Chapter 8. Local Data Storage

Chapter 9. SQL Data Storage

Chapter 10. Building Offline Applications

Chapter 11. Advanced Topics

Chapter 12. Push Using Web Socket API

For a more detailed list of topics see the outline.

No Comments