Wednesday, September 1, 2010

Java, an old maid?

Duke and Duke mom (by Silveira Neto)

A little bit of reflecting on the recent years..

Sometimes you think about what you're doing and reflect on your history. So does everybody, and so do I. And sometimes, I like to think about Java (the programming language, not the platform, which is a completely different matter) as an old, but still charming maid.

You know, she's grown older over the years, getting some wrinkles here and there. She likes to talk a lot. But in essence, she's still charming: she knows some old, well established jokes and shares your experiences, ups and downs across all the years. She's attractive, no question - but still: there are younger, more attractive gals coming around the corner. Scala's sure one of them (at least for me - remember her appearance here?). But I am still not leaving her - Java and Scala understand each other well, so why should I be giving one up for the other?

Okay, we're all a little bit edgy about her new significant other. But do we really know what will become of this?

Sunday, December 13, 2009

Expanding the Linux user base

I am currently planning a Christmas present to me and my parents: upgrading their computer to Linux from a foobar'ed Vista installation. And I am really looking forward to doing it.

You know, like every desktop you can buy at an electronics shop, this one was clearly a f$%!-up - too few memory to even run the bare operating system without swapping to the harddisk all the time. And of course lots of useless applications pre-installed which all startup upon system boot and eat away the little bit of RAM available.

Okay, 512M of RAM are an anachronism these days. But honestly, 512M should be enough for the basic tasks my parents perform with the device: checking & sending emails, writing letters, sometimes editing a spreadsheet and browsing the web or playing Patience. That's it. But as Vista is bad and requires at least one GB of memory to be used as operating system, I will have to do something about it.

Being the Linux enthusiast that I am I have been looking forward to going this step for months now. When I visit my parents during the holidays, I will spend some time with their workstation. I currently tend to parallel-install a Xubuntu Karmic so that they have the possibility to choose their operating system upon boot. As I have been using this Ubuntu derivate for a couple of years now, I am pretty familiar with it - the other Linux distros I have used throughout the years (Suse, Redhat, then Fedora, Debian, Crunchbang, Gentoo - not necessarily in this order) are fun stuff, too. But you stick to what you know best - and since I will have to provide the urgent-question hotline to my parents I will take the one I am using myself, so I really know what I am doing.

The process is easy and is properly supported by the installer which comes with Ubuntu - so what I will have to do is simply:
  • Defragment the Windows partition
  • Make backup copies of my parents' data
  • Start the Xubuntu installation
  • Resize the Windows partition (making it smaller to provide space for a new Linux partition)
  • Install Linux & additional software (Office, Browser, Email, Solitaire, CD Burning, ..)
  • Provide an initial getting started guide (usually HTML text with images)
  • Do a personal handover / pair session
That's it.

Linux is great, and it's easy. I really love this operating system.

Sunday, November 8, 2009

Amazon EC2 - First Steps

Today I took the time to go through the first steps using the Amazon Elastic Computing Cloud (= EC2) with a fairly simple dynamic web app. Nevertheless, I did not want to see what complexity I can put into a web application - this depends more on what you actually want to do - but see how the deployment procedure, infrastructure setup and everything related to it would work out.

And I must say, I am impressed with how easy it really is. Nearly no difference to using a local Tomcat installation from within Eclipse. But one step at a time, here's what I did:

Preconditions
- a 1.6.* JDK from Sun
- a local Tomcat installation (I am using 6.0.20, the current latest stable)
- Eclipse JEE edition, Galileo (3.5+)
- an existing Amazon Web Services (AWS) account

The existing account with AWS is necessary because the initial sign-up process takes a while. I had to wait about 18 hours until my subscription was actually performed. I guess they have to propagate the credentials through their internal systems - and that is what makes it slow.

Steps in short
- Install the AWS Toolkit for Eclipse using their update site
- Provide the account credentials in the Eclipse settings (account number, access key id, access secret)
- Create a dynamic web project using the Eclipse project wizard
- Create a servlet for the web project, also using the Eclipse wizard
- Edit the servlet (details below)
- Deploy to local Tomcat for testing, verify functionality
- Create EC2 Tomcat instance in Eclipse's "Server" view
- Deploy to EC2, test on remote host

Steps in detail


Installation of the AWS Toolkit..

..is self-explanatory if you have used the Eclipse Update Manager before. In case of questions, you can find a more detailed explanation at the Toolkit site.


Providing the AWS account credentials..

..is relatively easy: Just navigate to the proper section within Window > Preferences > AWS and enter your account ID, the key ID and the secret access key. You can find all of these details on your Security Credentials Page.


Create a dynamic web project..

..and a servlet within using the Eclipse wizards. This should not be that difficult since Eclipse does all the work for you like editing the deployment descriptor, provide a servlet mapping and the likes. I created a *very* simple servlet which takes to numeric parameters a and b and shows the addition result in the response. Here's the source code for the doGet() method, in case you are interested:

/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
* response)
*/
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
PrintWriter out = new PrintWriter(response.getOutputStream());
String a = request.getParameter("a");
String b = request.getParameter("b");
try {
int x = Integer.parseInt(a), y = Integer.parseInt(b);
out.println(a + " + " + b + " = " + (x + y));
} catch (NumberFormatException e) {
out.println("Invalid numbers (a=" + a + "b=" + b + ")!");
} finally {
out.close();
}
}



Deploying to the local Tomcat..

..assumes you already have your runtime configured properly. This means, Eclipse knows about where to find your Tomcat installation directory, knows which version of Tomcat it is etc. In case you have done all the configuration stuff, it should just be a matter of rightclicking your project in the Project Explorer (the Package Explorer or the Navigator should work, too) and choosing "Run As.." > "Run on server". You will be prompted to choose the server runtime you wish to use. After having chosen the local Tomcat installation, Eclipse should show the server startup in the "Servers" view (which can be opened with "Window > Show View > Other.. > Servers" in case you do not have it opened already) and automatically fire up your browser with the proper URL. In my case this was
http://localhost:8080/aws1/
which did not work out since I do not have any start pages, so my Tomcat presents me with a simple 404 in this case. Nevertheless I know where my Servlet is being mapped, so navigating to
http://localhost:8080/aws1/AdditionServlet
does the trick. I see the output telling me that a and b are invalid numbers (since they are null for that matter).
I just added the two parameters to the URL
http://localhost:8080/aws1/AdditionServlet?a=37&b=5
and get the nice result "37 + 5 = 42". Who would've thought - the answer to the Universe, Life and Everything[tm].


Create the EC2 Tomcat Instance..

..is as easy as setting up a local server instance. Just right-click the "Servers" view inside Eclipse, choose the EC2 Tomcat which is provided within the resulting dialog and fill in all the settings as described in the original tutorial.

After having set up the EC2 instance, just use the same procedure as before in order to start the server and deploy the web app ("Run As.. > Run on server", remember?). And voila - the web app runs on the remote host.


That's it. Fairly simple, isn't it?


Btw, Amazon will charge you for every started hour a full hour's rate (which is, for the eu-west-1 region), about $0.15 - but see the price listings for details. You have to provide valid credit card information in order to sign up for AWS and my test runs today amount up to about EUR 0.25.

Sunday, November 1, 2009

Xubuntu Karmic & Grub going backwards

I just installed the new Ubuntu Release, which had been release on October 29th, yesterday. I am using the Xubuntu derivative since the KDE 4 series is way too bloated for my taste and does not perform at all when being used with my ATI graphics card.

I really like the way Linux distros develop over time and - being a 8yr+ Linux user as I am - I must say usability, ease of use and everything has gone a far way into the right direction. Nevertheless I realised a step backwards when configuring my Grub bootloader yesterday.

I was impressed with the automatic detection for existing operating systems on my hard drives: I currently have WinVista, PC-BSD, Debian Lenny, Crunchbang Linux 9.04, Xubuntu 9.04, Fedora 11 Leonidas and the new Xubuntu 9.10 installed - kind of a zoo. Please note that the Vista installation shipped with my desktop and I am using it every second month when I want to play a 3d-accelerated game once in a while. And I am generally fond of Grub since the first day I started using it, switching from LILO at that time. Grub had a clear syntax for configuration, provided a *very* capable shell for tweaking boot options directly from the boot loader and it did not need to be run after changing some configuration options.

But then, the latter is not true any more. I have been using Grub 0.93 for a couple of years now and changing the delay Grub uses for displaying the boot options during startup was always a matter of just replacing the correct number in /boot/grub/menu.lst (or grub.conf) - et voila. But with the switch to the new and shiny Grub "1.97~beta4-1ubuntu3" (which comes with Karmic and already belongs to the Grub 2 series) I changed the delay and was advised to run 'grub-update' to apply the changes. WTF?! One of the great advantages IMHO was that I never had to re-run grub after tweaking the config. Not like LILO used to be. And with all the partitions and OSes on my hard disk, this grub-update took about 5 minutes to finish!

But then, I am not really aware of the changes Grub brings with the 2 series. It's all part of the commitment to bring boot times down to less than 10 second in the Lucid release AFAIK. We will see.

Blog Archive