Posts tagged with "java"


Review and pronounciation of Wuala!

Wuala logo

With all this excitement about cloud storage, I thought I'd try something a little different!

Pronounced "wah-lah", apparently!

Wuala is a cloud storage service by LaCie that comes with 5GB of free storage, with the option to purchase more. Like the sucker for advertising I am, I saw a label for the service on a LaCie external hard drive at an Apple Store, and was immediately interested!

What sets Wuala it apart from Dropbox and Google Drive is it encrypts your data before it's sent to their servers. Technically speaking, this means not even Wuala employees can access your data, unless you make it public (which you can do).

As an added bonus in a similar vein, Wuala's severs are based in Switzerland, Germany and France. While Europe's privacy laws are by no means perfect either, these days I feel safer having my data there than the United States.

Wuala's first login screen after installing

Usage

As I've mentioned previously, I dislike installing client software for online services, especially for something that may as well be public anyway. Given Wuala is performing local encryption before sending my data off however, I see their software as a necessary evil.

Once you install their client software (the subject for a future post), you're given the open to create a new Wuala account. Registration is fairly straight forward, and after responding to a confirmation email you're in your new cloud drive.

Wuala client after logging in

The client software runs in Oracle's Java or the OpenJDK (my choice) and should be pretty familiar to those used to the Finder, Nautilus, Thunar and the like. You can create folders, upload/download files, and set folders and files public or private (the default). They also have iOS and Android client applications.

What I really like however is it's ability to mount as a virtual local volume. Having tried on a fairly vanilla Fedora install, Wuala was able to create a new Fuse mount without any trouble, though the first time it took a minute or so to create it. Then I was able to drag and drop files from within Nautilus:

Accessing Wuala from the shell

And explore with the shell. Imagine what you could do with this!

Accessing Wuala from the shell

It has lots of other features, though I haven't looked much more into it yet. Something called "Time Travel" looks as though it could be a revision system of some sort.

So far I'm impressed. I'll report my day-to-day experience in the coming days.


Exception in thread "main" java.lang.NoClassDefFoundError

Icon from the Tango Desktop Project

In response to my previous Java post, I got a DM on Twitter from another university student asking if I'd come across the above error before. Often I do, when I'm programming in a dazed stupor at 3am, and I've done this:

% javac Something.java
% java Something.class

Instead of this:

% javac Something.java
% java Something

The error can be caused by any number of factors, but 99% of the time it's because of this. Much hair ripping has resulted from it!

(It turns out this was the problem. Glad I could help ^^)


A legitimate software question from my sister

Icon from the Tango Desktop Project

ARGH! Why can't the same software run on everything?!

Of course as developers we know why (the lowest common denominator problem, patents, turf wars), and can point out failed attempts to change this (*cough* Java), but sometimes it helps to see a less technically proficient user's take on what we've developed as software folk.

I suppose that's where web applications have the potential to shine, provided we move enough people onto standards compliant browsers. I very much doubt we'll ever have a consensus on a standardised desktop API, though I suppose Win32 came awfully close with a de facto one ;).


Java dying? Did Apple do it? An app store?

Classic Java logo

There's a lot of guff going on about Java right now, so I'm going to try my hand at clearing the air. Obviously my grammar has already taken a beating judging from the tersely efficient but horribly structured heading.

Java is dying

Dying in this case is a relative term, but despite the disappointing failure of the write once, run everywhere model that was supposed to solve OS dependencies on the desktop, Java is very much alive and well. Anyone who's been in any corporate, large enterprise environment knows that Java is thoroughly entrenched and isn't going anywhere any time soon. Like a boss. Google also uses it for tons of stuff, to afford myself the use of some sophisticated computer science terminology.

Oh yeah and Minecraft. Addictive games like that push my buttons and stroke my OCD tendencies WAY too easily, so I'm simply refraining from playing it. Call it an act of self preservation.

Apple killed JavaME on phones

There are two arguments about Apple killing Java. The older one is that Apple killed JavaME by not bundling it with the iPhone. I'd argue JavaME was functionally dead long before Apple came into the picture. I'd also say that to be fair, Android, webOS and Windows Mobile Phone Enterprise Corporate Home Premium Edition Service Pack 7 have done their bit to nip JavaME in the bud too. Granted Android [kinda] runs a Java VM in the form of Dalvik, but its legal standing is dubious at best, and it's unrelated to JavaME.

I remember writing a to-do list for my Motorola RAZR back in the day. It was easy enough to understand if a LittleCumbersomeAndVerbose, but it ran so horribly slowly and took so long to load I gave up on it.

To break up this post, here are the girls from some sort of scientific railgun show, with a phone, a laptop and a cup of coffee. Apt, right?

Apple killed Java on the desktop

The other argument is Apple killed Java on the desktop by removing it from Mac OS X. They didn't kill Java, they merely deprecated their internally developed version and passed responsibility back to Oracle and the open source community to provide it. They're in the process of doing so.

For those who don't remember, Apple developed a custom version of Java starting with Mac OS X 10.0 as a way to more thoroughly integrate Java apps into the OS and to afford more visual consistency. If you recall, for a long time Java apps didn't really look like their host OSs at all (and in certain circumstances they still don't, at least not very well). The first Java I ever wrote was on my iBook in 2001, go figure.

Depending on who you talk to, Apple engineers were also forced to craft their own Java implementation given Sun's lack of interest in the platform. If that sounds familiar, this is just the apathy that Macromedia and Adobe displayed for the Mac with their Flash plugin that was so slow, unreliable and insecure that Apple was forced to write a container around it for Safari. Shipping an older version didn't help either, but hey!

Apple were small fish before and had to accept whatever they could from the high and mighty, now they are in a position to dictate terms... and Steve Jobs certainly holds grudges! As Adobe is realising now that Flash is not included by default in the MacBook Air, if Oracle wants Java on the Mac, it's up to them now to prove to Apple customers that they need it. It also puts native applications at an advantage, which is a convenient fact for Apple ;).

You know what'd be cool?

I'd actually be really interested in seeing a cross platform Java app store to prove to us that write once, run everywhere is not only viable, but preferable to vendor lock-in. They could sell Minecraft, and auto-update software like NetBeans and Makagiga. Oh yeah that reminds me, Makagiga is pretty cool. But that's for another post.

As I started this post by saying, Java is thoroughly entrenched in the enterprise. Whether or not Oracle has any interest in recapturing the consumer space where Java needs the most help is the ultimate question.


My latest project worked!

Icon from the Tango Desktop Project

With my dad, sis and I moving internationally again and with this latest project, I haven't had much time for blogging or tweeting these last few days. I'm really excited though, because I just finished a really unconventional project for a client and it worked beautifully!

I'm not allowed to discuss the Five W's, but suffice to say it used a lot of a certain flavour of Java and a really ancient database. I'm talking stone tablet ancient. And it worked! Yays! Alas for the sake of my anemic public resume/portfolio, this will be yet another thing I can't add to it for NDA-like reasons. Oh well, I learned a heck of a lot and got lots of experience.

Now I'll be taking a small sabbatical and helping my dad and sis move in and organise whatnot. Will be nice ToLiveWithoutLongCamelCase and dusty old manuals with yellowing pages that made me sneeze for a while ;).


Dr Karl answers your programming questions

Dr Karl

One of the world's best dressed and most friendly scientists, Dr Karl answered a question about muscle exhaustion.

Why do arm muscles get tired? @maxiewawa Mmm. Ca++ exhaustion, glucose exhaustion, lactic acid overload, neurotransmitter exhaustion, etc.

I can relate, whenever I write C++ code I get severe muscle exhaustion in my fingers and brain ;-).

By contrast, Java shifts some of that mental exhaustion from the brain to the fingers WithItsExcessiveCamelCaseMethods. I think wrapper methods saved me from serious finger ligament damage and carpel tunnel syndrome.

This post that I constructed entirely out of an intentionally misread quote was brought to you by a Grilled Cheese Sandwich.


Main methods in Python, Ruby, Java stuff

Main Street

I've decided to put my code snippets blog idea on hold because I don't have time to be maintaining a separate blog right now. Had I started it, this would have gone there.

Not having main methods never used to worry me, but since studying Java again I really like being able to have an application kick into action without having to create an instance of it manually.

To illustrate what I mean, here's a crappy Java application that I merely have to execute from the command line for it to display Bender's favourite words.

MainInJava.java:
public class MainInJava
{
  public static void main(String[] args)
  {
    System.out.println("Kiss my shiny metal arse");
  }
}

Now here are roughly equivalent applications written in Ruby (my formerly favourite scripting language) and Python (my formerly favourite scripting language, and now my favourite scripting language again!):

MainInRuby.rb:
#!/usr/bin/env ruby -w

class MainInRuby
  def initialize()
    puts("Hello, world!")
  end
end

MainInPython.py:
#!/usr/bin/env python -3t

class MainInPython:
    def __main__(self):
        print("Hello, world!")

If you were to run either of these example applications, nothing would happen. The initialize and __main__ methods aren't run because merely running the application doesn't do any instantiation. Ruby and Python expect you to create and run an instance of the application in the source.

The proposed workarounds if you really want Java-ish main method equivalents in these languages are to write these lines of boilerplate outside the class.

MainInRuby.rb:
if __FILE__ == $PROGRAM_NAME
  # Put "main" code here
end

MainInPython.py:
if __name__ == "__main__":
    main()

I understand what these functions do, but for scripting languages that pride themselves on making life easier compared to heavy languages like Java, these don't seem all that intuitive or elegant.

I suppose one could argue that I've been corrupted into thinking I need a main method and that I haven't bothered to learn the Ruby or Python way of doing things. They may be onto something ^_^.

__EXIT__


Choosing between Ruby/Tk or Java Swing

Java Swing code

UPDATE: Alex has suggested I try Ruby with Qt. Genius!

My family has always had an obsession with the Monopoly board game, and since my mum died the remaining Schade clan has clung onto it even more as a family tradition. Because I have some spare time over the holidays I thought I'd create a computer version of Monopoly but with the place names and chance cards to do with places and experiences we've been to and had. Trouble is, I'm not sure what graphical toolkit and language to use!

The problem is we'll (hopefully) be taking this game to Europe, but our laptops have a smattering of different operating systems and configurations. My sister has a MacBook with Snow Leopard, I have a MacBook Pro with Snow Leopard and FreeBSD, and my dad is still forced to use Windows on his work laptop. Ideally I'd like to have my crappy little game being able to run on each.

Tickle Ruby with Tk or be the King of Java Swing?

Given I've been dabbling in Ruby again and have relearned the joys of Smalltalk like blocks, my first choice was to use Ruby with Tk because its fast to develop, seems to be relatively simple and comes with the default Ruby environment without installing anything extra, but I have far more experience with Swing in Java. As with everything in Java (and with me, ha!) its incredibly verbose to do even simple things, but its not terribly complicated unless you desperately want to do it the "correct" OOP way.

Judge me if you will, but for some reason I also really, really like the Metal Java Swing interface. Some people avoid it like the plague and allow their Swing applications to resemble the host operating system, but I reckon it looks classy.

Example Java Swing window with metal interface

I suppose I could come right out of left field and use JRuby with Swing, that way I have the familiar widgets and layout engines I'm [relatively] used to with a quicker to develop, RAD and Agile friendly language. Perhaps I'm getting a bit too ahead of myself though, would it be easier just to stick with Java on this one? Object serialisation (which I know how to do in Java but not Ruby) would make it great for saving and loading existing games too. Then again, perhaps I should force myself to branch into something new to learn something different.

Looks like I won't be deciding tonight!


Writing code that ends cleanly without breaks

Super detailed diagram!

You'd think transitioning back to university studies after working would mean I'd be learning more about so called "correct" programming techniques, but I've actually found the opposite is true! Apparently I'm also incapable of writing catchy titles for programming posts.

It's hard to describe, but in high school programming classes I learned its important to bring programming logic that may have strayed off in different directions back to a single point so a method can cleanly exit. In this way, each block has a clearly defined beginning and end.

This can be demonstrated using a loop. In this completely pointless Java example we're traversing a linked list of <Strings> looking for an awesome anime character. To preempt any comments, yes I could have used a for each loop, but that's not the point I'm trying to make.

while (linkList.hasNext())
{
  if (linkList.next().equals("Her Senjougharaness"));
    break;
}

In the above case we have one entry point, but we're breaking out of the loop instead of allowing it to cleanly finish (in fact in this case it never will finish!). This works, but a more elegant solution is to modify the condition of the loop itself:

boolean found = false;
while (!found && linkList.hasNext())
{
  if (linkList.next().equals("Her Senjougharaness"));
    found = true;
}

In this case, once we've found what we're looking for the loop isn't merely broken out of with a break statement, but is allowed to cleanly finish and gracefully return control to the parent because the condition of the loop has been changed and it terminates itself.

Funnily enough I've been told by people marking my assignments I've been creating unnecessary extra work for myself demanding my loops and methods be structured like this, and they're probably right. Nevertheless I've been wired to not accept any other way; unclean exits just look ugly as sin from a design standpoint to me, and I know it's not the "correct" thing to do. I think!


On Java inner classes and whatnot

Classic Java logo

A few weeks ago I discussed the different ways to include multiple classes in one file, and one of the comments questioned my use of a class within a class. Apparently when they tried to do it in earlier versions of Java all they got in return was grief. I could say something there about swearing being the common language of all programmers but I'll leave it at that :).

From what I can tell, so called inner classes were introduced in Java 5, and they allow you to do some pretty cool stuff. By having an inner class defined within an outer class:

  • the inner class can access the data members of the outer class without the need for setter and getter methods
  • tidyness and encapsulation es ist gut so!
  • if you start getting into using C++'eque <T> object types (something I'm learning now) the outer and inner classes automatically share them (which they need to anyway)
  • of lesser importance, you only need to give the Java compiler one file to compile two or more related classes, and you only need to work on the one file

When you compile a java class with inner classes, the resulting compiled bytecode class file whatsits (to use the technical terminology) are divided into outer classes and inner classes with a dollar sign:

% javac OuterClass.java
% ls -l
OuterClass.class
OuterClass$innerClass.class
% echo Grilled Cheese Sandwich
Grilled Cheese Sandwich

My Java linked list stack post shows how a outer link list class uses an inner Node class if you want to check it out. Another example is the Iterator class which belongs to Java's new and very nice to use lists that implement the List interface, other things I'll be blogging about soon once I've had a chance to play around with them more.

Personally I can already see how these could be abused, but I guess as with any great power comes great responsibility, and with any blog post comes the need for a cliché apparently!