2010-11-14

The future of Java

The last months (after Oracle has completed the merger with Sun) were full of insecurity and discussions within the Java developer communities about the future of Java. Many have blogged about their fears. I personally followed the discussions but I felt, the best thing is to wait. People are so fast with their interpretations and guesses how others will behave.

In parallel there were discussions about Apple stopping support for Java on the Mac etc etc.

Even although Oracle already told they are strongly commited to Java, NetBeans and other famous Sun products, discussions were going on.

Finally a few further commitments have come to public:

IBM joins OpenJDK
http://blogs.sun.com/mr/entry/ibm_to_join_openjdk

Oracle and Apple Announce OpenJDK Project for Mac OS X
http://www.apple.com/pr/library/2010/11/12openjdk.html

This means, that big players decided to go the Java and Open Source path. And it is important to unite the forces. Working together is far better than fighting each other.

When I decided to switch away from my Windows-only-development, one major reason was: There are many other operating systems gaining market share, like several flavors of Linux (Ubuntu, Mint, Redhat, Debian etc) and Apple - and I can't say for sure which ones will be there in the long run, but I want to provide security to my customers, that they can benefit from the software for a long time. - Java was a good choice in the past and now we can again be sure that it still is a good choice. The idea of Java - "write once, run everywhere" - has saved me from a lot of work in the past (compiling for different architectures not required, no building of different styled setup procedures etc). There are people mentioning that the write once, run anywhere phrase is not quite true, because not available for really all operating systems and often there have to be exceptions made for dealing with different operating systems. - Well, this is partly true, when it comes particular features, that might be even not available on all operating systems. Fortunately for such cases Java can be coupled with C(++). For availability: Java is available on more operating systems than most other languages (see http://www.java.com/en/download/manual.jsp).

BTW: C(++) is also a language, that is around and will be around for a long time and I hear nobody complaining that it is developing too slow for example. And I really prefer thinking carefully before putting new features into the language. There must be many things considered. It is important to do no harm to the language.

Oh, there is finally also an official podcast from Oracle for Java developers:
http://blogs.sun.com/javaspotlight/
Of course this is biased and the Javaposse (http://javaposse.com/) is still the first address when it comes to Java podcasts.

We have exact plans for the next versions of Java:
http://blogs.oracle.com/javaone/2010/09/plan_b_wins.html
http://openjdk.java.net/projects/jdk7/features/

And we get exactly what we need next for NetBeans (the first-class Java IDE):
http://netbeans.dzone.com/nb-generate-simpler-rest

Related posts: The dawn after sunset, The programming language, Popular Java myths, Java applications on the desktop, The community.

2010-11-04

Self-Healing Linux

Until yesterday I only occassionally read about it, but yesterday I experienced my Ubuntu workstation self-healing from freeze.

I did not take care about how many applications were running and as doing a lot of things in parallel that all take quite a while (downloads in background, file copy operations and installations within virtual machines) I completely forgot about how many virtual machines were started. I was about to start another one when everything started to get really slow. I have 4 GB memory and a small swap partition (because during normal work I hardly get the memory of my Ubuntu full).

The memory at this time really got filled up completely and everything got veeery slow. I wasn't either able to switch windows. I was able to switch to the text console which also was very slow.

I wanted to login and kill a few tasks when I got messages broadcasted to my text console saying that the memory was exhausted. Shortly afterwards I got messages that the system identified Firefox and Thunderbird doing nothing and they were closed (maybe because just consuming memory at this moment). And finally it told that the last VirtualBox machine was consuming a lot of system resources and - was killed.

Flup, flup, everything was fine again. - And hadn't either time to do it manually. And it was doing exactly what I would have done manually - killing the last started virtual machine and closing the applications that were doing nothing (downloads were already finished).

That is simply awesome!

2010-10-25

User lock down

In many big companies it is quite normal to lock down most features at the desktop that would allow the user to adjust settings and install software. Basically there are strong limitations for the user.

I can understand the reason, why this is done: To reduce security risks and to avoid users accidently change something that they don't know how to change back.

So the overall lock-down is a way to reduce required end-user support.

The other side of the medal is:
  • Every person is different and hence works in a different way. Hence the same configuration can't be the optimum for all users.
  • Depending on the position different additional tools might be interesting for different users boosting their productivity.
  • For the most users it is simply demotivating when they are locked down.
  • Users will find workarounds for many lock-downs (e.g. using http://portableapps.com/ on a memory stick).

Because of the disadvantages I want to point out alternative options:
  • Lock down only where and when necessary.
    Some users - especially the beginners - either prefer a lock down. Those are the users who have some fear in front of a computer to mess something completely up. Other users have detailed know-how on how what operations to avoid and how to prevent themselves from viruses as good as possible. You could introduce a point-system or simply lock down a users PC only when a particular support time per month is exceeded.
  • Set a time limit before pushing default configuration.
    In some companies when a user calls for IT support, there is a maximum time of 15 or 30 minutes to solve the problem - otherwise the user gets a new image (with default configuration). That way it is ensured that your staff does not loose plenty of hours to solve end-user problems.
  • Train the users.
    Train them security and other basics (who to distinguish executable files from data files, where to never confirm approvals in popups, don't running executable attachments from emails, how to properly install and remove software etc etc etc). The user who is aware of the risks cautious and prudent.
  • Migrate to Linux on the desktop.
    Linux is more secure and less prone to break down after several software installations, uninstallations or upgrades. Also backup of local settings is easier. And it is a proven fact that Linux users require less support - even if they are no geeks! Everybody I talk to, who gives Windows and Linux support, tell me that and this is matching my own experience.

Related posts: Your holy machine, Why Linux?, Going Linux, The community.

2010-10-18

Locale configuration on Ubuntu

OK, first I was annoyed that changing the date format to ISO (yyyy-mm-dd) is not so easy on Ubuntu as it was on Windows. Yes, but - as usual in the Linux world - you are much more flexible on Ubuntu.

I am a special case: I want my menus and environment in english, I am located in Austria (so I want currency in Euro, thousands separator is dot and not comma, ...) but the date format I like to have in ISO format (and not the german default dd.mm.yyyy) because I find the ISO format simple the most practical (well, I am working in IT and the ISO format is the best to sort if you have just plain text). Under Windows I had a german OS (because I needed to support mostly users with german version) and changed the date format in the international settings.

Situation under Ubuntu is different: You install an english base system and install whatever languages you like through:
  1. "System - Administration - Language Support"
  2. Click "Install/Remove languages..."
  3. Choose the language(s) you want to support - every user can choose the language he/she likes at login (last used language is remembered as preselection).
  4. In the "Language for menus and windows" list you can drag and drop languages to specify priorities. The language the user chooses at login is taken first of course, but usually the language dragged to first place here is the default for new users. Attention: When installing a new language, it is usually put on top and somehow the system tries now logging in all existing users with that language (if they don't change it at login) - so doing changes here overwrites the last remembered language for the users. This behavior might be desired or not...
  5. In the text tab you can change the country you are in (this is similar to the Windows international settings - but you can't override parts of the country settings here.
So first, I found that I have less options than under Windows - until I discovered these options that you can set in your /etc/default/locale (a plain text file):
 LANG="en_US.UTF-8"  
 LC_CTYPE="en_US.UTF-8"  
 LC_NUMERIC="en_US.UTF-8"  
 LC_TIME="en_US.UTF-8"  
 LC_COLLATE="en_US.UTF-8"  
 LC_MONETARY="en_US.UTF-8"  
 LC_MESSAGES="en_US.UTF-8"  
 LC_PAPER="en_US.UTF-8"  
 LC_NAME="en_US.UTF-8"  
 LC_ADDRESS="en_US.UTF-8"  
 LC_TELEPHONE="en_US.UTF-8"  
 LC_MEASUREMENT="en_US.UTF-8"  
 LC_IDENTIFICATION="en_US.UTF-8"  
 LC_ALL=  
So you can really define the behavior of plenty of formattings!
The content of my etc/default/locale is now (LANG and LANGUAGE was set when I changed settings in the GUI, LC_DATE and LC_TIME I have added manually:
 LANG="de_DE.utf8"  
 LANGUAGE="en"  
 LC_DATE="en_DK.utf8"  
 LC_TIME="en_DK.utf8"  

I have added LC_DATE myself (just a wild guess because it is not mentioned in the list above - which I found on the internet), for Thunderbird for example LC_TIME was sufficient.

Probably this obsoletes post "Firefox change default page format" (but did not check).

Related posts: Firefox change default page format, OpenOffice and LibreOffice starts slow, Default paper size in Open Office, Normal.dot in OpenOffice or LibreOffice.

    2010-10-06

    The Open Source idea

    As open source software gets more and more popular, when talking to other people or reading about open source, I often notice that people seem to get things (partly) wrong. So I want to clear up a few major missinterpretations:
    1. Open Source does not necessarily mean (completely) free (in the sense of money costs and legal permissions).
      There are a lot of writings about free as in beer or free as in freedom or things like that. I do not find that very clear.
      The point is:
      • Some software - when you buy it - comes along with the source code. Reason: Companies (especially since economic crisis or because of general fears) worry about their investment. What, if a company fails or goes up in flames? If the customer has the source code then there are at least two options if changes are needed: Have somebody in the company looking at the source code and implement the changes or hire somebody doing that work.

      • For some software the version that includes the source code is only very limited - either in functionality or from legal permissions.

      • And then of course there is real completely free and open source software that costs nothing and you can do with it what you want. The GPL and related licenses only have the limitation that derived work must be released under the same (or compatible license) - that way you get open source spread like a virus ;-) .

    2. How can a company survive from the financial point of view when giving software away for free?
      This is the most asked question when it comes to open source in business. Some companies give away base products away for free hoping to make business with AddOns and enhancement requests. This business model sometimes is successful. Unfortunately in many cases the base products are quite useless without the additional plugins/addons and developing those on their own is often not an option for companies.

      But what is completely forgotten by people asking this question: You would never accept to pay your plumber license fees each year for just having tubes in your walls. - You pay the plumber when there is work needed (repair, put additional tubes etc)! You also would never accept to pay your haircutter a license fee (even if your haircutter declares officially he/she will use the money to improve haircutting skills). You pay the haircutter when actually hair cutting is needed.

      The same should apply for software: Money for work.
      And the idea of free and open source software is that you pay for the planning and implementation work. Once that is done, the good thing with software is, that it can be copied around. Other than eating, haircutting etc software does not go rotten or fades away.

    3. Software as a service cannot be free in the long term.
      In the last years companies offering web services or web applications hosted by those have multiplied like rabbits. Most of them - at least initially - were free. Now I observe them becoming commercial one after the other. The point here is that for the customer using these services seems to be completely hassle free. Yes, no need to maintain server hardware (farms), watch and control server tasks to be up and running etc. - But that work is now outsourced to the provider of that web service. There are at least power costs and hardware that needs to be replaced (HDs, burnt motherboards etc) from time to time. There is actual maintenance work needed and that costs money. This is different from having software that does not need maintenance work by itself. Software maintenance work is usually only needed, when somebody else breaks major interfaces - which is maybe sometimes done even with the intention to create the need of maintenance work. However, this is not the idea of the open source movement. The idea of the open source movement is more to boost innovation. But: With big open source products there also comes big requirements of infrastructure and related services. For example: There are plenty of repository servers for the Linux kernel and all the software available. There is maintenance work required for all those. So how can that service be offered in the long term? Well, I assume, that many of those servers are maintained by people who see this as their contribution - instead of paying fees, they set up a server and contribute that way. Costs less that usual maintenance license fees - and nobody pays taxes for it. :-)

    Related posts: Paying for free and Open Source, The Open Source movement, The license keys, Why Linux?, Going Linux, The small software vendors, The community, Popular Ubuntu desktop myths.

    2010-09-26

    Install NetBeans on Ubuntu 10.04

    Why should one do a description of installing NetBeans on Ubuntu - it's in the repositories and just a few clicks?

    The reason is: Installing it through the repositories you will get problems later when trying to upgrade NetBeans with the builtin-update tool. Apart from this I prefer to download the full package from http://netbeans.org/downloads/index.html and deactivating the modules I do not need - at the moment. I always make sure that the sun (or now Oracle) JDK is installed (there were problems in the past with OpenJDK - and although they should be solved I still go with the Sun/Oracle one.

    Preparations:
    • You can install the Sun/Oracle JDK through the repositories or do the manual install.
    • To make sure, the correct Java is used, install galternatives (then available through Applications-System Tools-Alternatives Configurator) and then go through each item in the list on the left. There are quite many Java related tools that - after installing the Sun/Oracle JDK now offer that one as second alternative. For all the Java related tools select the new alternative from Sun/Oracle JDK.
    • If you manually installed new JDKs - e.g. after an update has been released, you might have to change the symlink accordingly at /usr/lib/jvm/java-6-sun using the ln command, eg:
      cd /usr/lib/jvm
      sudo ln -s java-6-sun-1.6.0.20 java-6-sun

    So here are my steps for the NetBeans installation:
    1. I create a folder under opt for NetBeans:
      sudo mkdir /opt/netbeans
      I don't use the profile folder for installation because this reminds me too much of Windows. In the profile folder there should only go data and I backup this folder more often than other ones. It does not make sense backup the programs all the time.
       
    2. Then I set the permissions for the normal user:
      sudo chgrp theuser /opt/netbeans
      sudo chmod ug+rwx /opt/netbeans
      If you want to have more users work with NetBeans then replace theuser with a group that all the users are member of - however this solution is only if you trust those users regarding updating and activating plugins etc. Otherwise install as a user with sudo permissions and do not set the permissions above to prevent other users from updating.
       
    3. Then I install all NetBeans components (running the installer as normal user) in that folder (/opt/netbeans). There will be usually a subfolder for netbeans (including version in the folder name) and also for Tomcat and Glassfish.
       
    4. I also extract the javadoc downloaded from http://www.oracle.com/technetwork/java/javase/downloads/index.html into /opt/netbeans as jdk-6-docs or so. In former times I put it under the jdk folder but as I upgrade the JDK itself more often than the documentation this always needed additional work to move the doc to the new folder or change links when they got broken after deleting older javadoc.
       
    5. To make the javadoc available in NetBeans launch NetBeans and go to Tools-Java Platforms, switch to the javadoc tab and add the javadoc root folder - in my case /opt/netbeans/jdk-6-docs.
       
    6. When I add external libraries (Tools-Libraries) I also save/extract them previously to another folder - not within my profile (for reasons I mentioned earlier) - of course an option would be /opt/libs or so - I have a completely different separate folder for shared data and libraries that I backup from time to time (less often than profile data).
    Related posts: The IDE and the libraries, The programming language.

    2010-09-10

    Shell scripting your desktop windows

    In Java my limits are often what is offered in every OS - and what is inside the JVM.

    One thing, I often needed in the past under Windows is to get the title (or other information) of the active window. I was using Windows API to get the information needed. Under Linux/Ubuntu things are different - and more complicated due to different desktop environments, I thought. And how to access those APIs with Java?

    Well, it turned out, that I am completely wrong and once again was trapped in my old habits from Windows.

    Linux offers commandline tools - not only to get window information - no, also to manipulate windows, move them to different desktop etc. As I could start an application on a different machine and showing the window on my machine, I can either see the machine name in window lists. A commandline program can be easily used from within Java and output can be retrieved easily. Awesome!

    It again turns out, that Microsoft Windows is totally poor in commandline tools. However, I could implement a similar small exe that gets me the active window title through API on windows and does console output that can be retrieved by a Java application or can be used in batch files.

    If you are a Linux user, have a look at the following commands:
    • wmctrl
    • xprop
    • xwininfo
    All these tools can be used even from within shell scripts - awesome!

    With xprop -root you get exhaustive information about windows.
    Using xprop -root | grep _NET_ACTIVE_WINDOW\(WINDOW\) you get the active window handle. You can then use the address in wmctrl -l | grep theaddress. The only quirks is that in wmctrl the address might have an additional 0 after 0x so you should search for the part after 0x only in the output of wmctrl.