Latest Updates: java RSS

  • Articles

    The Google Go programming language

    Stii 2:57 pm on November 11, 2009 | Comments: 2 Permalink | Reply
    Tags: c, , google go, java, pascal, , programming languages,

    Lately Google announced a wide array of new products and features. The Google Chrome browser, Google Wave, Android and Google Chrome OS are the ones immediately coming to mind. This morning I saw they released Go. Their own experimental programming language.

    Go is not a scripting (a.k.a. interpreted) language, but a compiled language like C or C++. It looks very, very simple compared to C/C++ and according to them it was born from their frustrations with said languages. This has potential to become popular should they drive it sufficiently.

    The syntax of Go looks like a mix of Python, C, Java and Pascal. Have a look at this:

    package main
    
    import (
        "os";
        "flag";  // command line option parser
    )
    
    var omitNewline = flag.Bool("n", false, "don't print final newline")
    
    const (
        Space = " ";
        Newline = "\n";
    )
    
    func main() {
        flag.Parse();   // Scans the arg list and sets up flags
        var s string = "";
        for i := 0; i < flag.NArg(); i++ {
            if i > 0 {
                s += Space
            }
            s += flag.Arg(i)
        }
        if !*omitNewline {
            s += Newline
        }
        os.Stdout.WriteString(s);
    }
    

    I can say this: It looks friendly! I like the sugar.

    Some of the features makes a lot of sense and I hope this will evolve successfully. Just look at the names behind this little experimental project and you’re bound to get excited! I’d love to know what C and C++ stalwarts think.

    PS: Love the origin of the name:

    “Ogle” would be a good name for a Go debugger.

    I concur.

    Welcome back! You should subscribe to my RSS feed here.
    You should follow me on Twitter here
    You should follow me on Gatorpeeps here.

    Save Cape Town City Ballet
     
  • Articles

    Developing Android apps using Netbeans

    Stii 12:34 am on June 10, 2009 | Comments: 9 Permalink | Reply
    Tags: android, java, , sdk

    I prefer Netbeans to Eclipse. I know very little Java, but I’ve kind of grown used to Netbeans while exploring Groovy and Grails. Eclipse is the de facto standard for developing Android apps, although there are a Netbeans plugin. Here is how I got my Netbeans 6.5 instance to work with Android.

    First of all, you need to install the Netbeans Android plugin called nbandroid. In Netbeans, go to Tools > Plugins > Settings and click on the Add button and add the plugin update URL: http://kenai.com/projects/nbandroid/pages/Install. Install the Android plugin.

    You need to download and extract the Android SDK. The latest version can be found on the Android Development site. Extract the zip file.

    The file structure for the new SDK has changed and Netbeans won’t work with the new SDK as is. You have to do the following:

    ~$ cd path/to/sdk
    ~/path/to/sdk$ cp -R platform/android-1.5/* ./
    

    Start a new Android project in Netbeans and in the new project window, click the Manage Platforms button.

    netbeans manage platforms

    Select the “Google Android Open Handheld Platform” option and click the Next button.

    netbeans select platform type

    Navigate to the path where your SDK is (the path to the prepared one as per the above mentioned steps). Click the finish button and it should be good to go.

    netbeans select android sdk

    Before you start hammering away at your newly created Android project, you need to set up an emulator to test your application, else you would not be able to test anything.

    You need the API target id in order to create an emulator. Do it as follows:

    ~/path/to/sdk$ android list targets
    Available Android targets:
    id: 1
         Name: Android 1.1
         Type: Platform
         API level: 2
         Skins: HVGA (default), HVGA-L, HVGA-P, QVGA-L, QVGA-P
    id: 2
         Name: Android 1.5
         Type: Platform
         API level: 3
         Skins: HVGA (default), HVGA-L, HVGA-P, QVGA-L, QVGA-P
    id: 3
         Name: Google APIs
         Type: Add-On
         Vendor: Google Inc.
         Description: Android + Google APIs
         Based on Android 1.5 (API level 3)
         Libraries:
          * com.google.android.maps (maps.jar)
              API for Google Maps
         Skins: HVGA (default), HVGA-L, QVGA-P, HVGA-P, QVGA-L
    

    Say you want to test using the Android 1.5 API, you need to specify the target as 2 (see? id: 2) With this information in your arsenal, type the following:

    ~/path/to/sdk$ android create avd -n avd_1.5_1 -t 2
    

    The -t 2 section of the command is the target id as per the previous command.

    The last step is to add the following to your project’s build.xml file.

    <target name="-pre-init">
            <property name="emulator.options" value="-avd avd_1.5_1"/>
    </target>
    

    I.e. your build.xml file should look something like this (without the … truncated … part):

    <?xml version="1.0" encoding="UTF-8"?>
    <project name="AndroidApplication2" default="default" basedir=".">
        ... truncated ...
        <target name="-pre-init">
            <property name="emulator.options" value="-avd avd_1.5_1"/>
        </target>
    </project>
    

    That’s it! Now make it do something simple and run your application. It should open an Emulator window and run your application. Nifty!

    android emulator

    Here are the sources that solved my problems:
    http://wiki.netbeans.org/IntroAndroidDevNetBeans
    http://kenai.com/…;

    Save Cape Town City Ballet
     
  • Articles

    Quest for holy Grails

    Stii 5:04 pm on June 8, 2009 | Comments: 1 Permalink | Reply
    Tags: Grails, , java, , web development

    groovy_transparentThis weekend I decided to take some me time and learn something new. I’ve been looking at Groovy a little and decided to play with Grails (A Ruby on Rails like MVC web development framework for Groovy) a couple of hours over the weekend. I downloaded the minibook “Getting started with Grails” (which you can download for free upon registration at InfoQ) and started working through it.

    I found it all surprisingly simple, even though it would be safe to say I have almost ZERO Java experience or knowledge. I found it all very intuitive and well explained, although I should add that I have not yet completed the entire exercise.

    I’m using Netbeans as the IDE of choice and it is pretty impressive! At first I found the project structure a little confusing as it is different to the Grails file system.

    netbeans grails project

    Found that all I need to do to see the Grails file system is to click on the Files tab in the project window.

    netbeans grails file system

    I pretty much followed the instructions in the book I downloaded. I’m sure it would get harder and more tricky, but so far so good. I’m loving it already! Now the trick would be finding more time for playing…

    Save Cape Town City Ballet
     
  • Articles

    Java is Groovy and Groovy is Java

    Stii 10:02 pm on May 21, 2009 | Comments: 11 Permalink | Reply
    Tags: , java, ,

    groovy_transparentgroovy |ˈgroōvē|
    adjective ( groovier , grooviest ) informal dated or humorous
    fashionable and exciting : sporting a groovy new haircut.
    enjoyable and excellent : he played all the remarkably groovy guitar parts himself.

    That is as defined in my beloved and trusted Mac Dictionary. I have to do a little Java project soon. Not because I want to, because I HAVE to for Afrigator. Don’t get me wrong, I think Java is great and powerful. I have a healthy dose of respect for it. Problem is, I’ve never done anything remotely formal in Java. The only experience I have with it was when I checked it out about 6 years ago. Safe to say, I’m a n00b.

    The problem is that I’m quite busy these days. Time and energy is not much for attempting learning a mammoth like Java.

    Hello, Groovy! Groovy is a dynamic language specifically for the Java platform. Groovy is built for the JVM, making it easy for Java to integrate with Groovy vice versa. In Netbeans, they went a far as not even having an option to create a Groovy project. You create a normal Java project and then add Groovy classes to it. That is how tightly it seems integrated, which is good news for a n00b like me :)

    The syntax itself seems very close to that of Ruby. Lets look at these examples (from the excellent article by Gerald Bauer – Groooooovy Babe: Jazzing Up Plain Old Java)

    Here is some Java code

    import java.util.*;
    
    public class HelloWorld
    {
      public static void main( String args[] )
      {
         List country = new ArrayList();
         country.add( "Canada" );
         country.add( "Austria" );
         country.add( "Brazil" );
    
         Collections.sort( country );
    
         for( Iterator it = country.iterator(); it.hasNext() )
            System.out.println( "Hello " + it.next() );
      }
    }
    

    The same in Groovy ( note the code reduction compared to Java :) )

    country = [ 'Canada', 'Austria', 'Brazil' ]
    country.sort
    country.each { println "Hello ${it}" }
    

    And in Ruby

    country = [ 'Canada', 'Austria', 'Brazil' ]
    country.sort
    country.each { |country| puts "Hello #{country}" }
    

    To top it all off, they even have their own Rails-like web framework called Grails (Groovy on Rails). I’ll check that out in due time.

    All in all, Groovy feels much more comfortable and familiar to me. I’m looking forward to this little challenge and will probably write about it as I go along. Aslam Khan assured me that it is solid and he even have some Groovy code out there in the wild in production which is comforting! That and knowing someone who is an expert to ask for advice when the going gets rough, since I’m fairly sure it will get rough due to n00bn3ss!

    Save Cape Town City Ballet
     

About Me

Software developer at Afrigator.com Love Python, do PHP.
c
compose new post
j
next post/next comment
k
previous post/previous comment
r
reply
e
edit
o
show/hide comments
t
go to top
esc
cancel