Wednesday, December 28, 2011

Sunday, December 25, 2011

Useful eclipse plugins


Eclipse Marketplace
http://marketplace.eclipse.org/content/eclipse-marketplace

Subversive - SVN Team Provider
http://marketplace.eclipse.org/content/subversive-svn-team-provider

Subclipse
http://marketplace.eclipse.org/content/subclipse

EGit - Git Team Provider
http://marketplace.eclipse.org/content/egit-git-team-provider

FindBugs Eclipse Plugin
http://marketplace.eclipse.org/content/findbugs-eclipse-plugin

UMLet - UML Tool for Fast UML Diagrams
http://marketplace.eclipse.org/content/umlet-uml-tool-fast-uml-diagrams

Mylyn
http://marketplace.eclipse.org/content/mylyn

Checkstyle Plug-in
http://marketplace.eclipse.org/content/checkstyle-plug

AnyEdit Tools
http://marketplace.eclipse.org/content/anyedit-tools

Eclipse Color Theme
http://marketplace.eclipse.org/content/eclipse-color-theme

Data Hierarchy
http://marketplace.eclipse.org/content/data-hierarchy

JAutodoc - Eclipse Plugin
http://jautodoc.sourceforge.net/

syntaxhighlighter

syntaxhighlighter for highlighting code in blogger: http://alexgorbatchev.com/SyntaxHighlighter/integration.html

SCJP

package test1;

import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;

interface IMain
{
    // interface method can declare exception in its signature
    void method() throws Exception;

    //void method6();
}

public class Main implements IMain
{
    // main can be final, can be overridden, cmd line arg starts with parameters
    public static void main(String[] str) throws ClassNotFoundException
    {
        System.out.println("Main");
        new Main().method1();
    }

    //constructor can throw exception
    public Main() throws ClassNotFoundException
    {
        throw new ClassNotFoundException();
    }

    public void method()
    {

    }

    public void method1()
    {
        //can have empty try catch block
        try
        {

        }
        // j2se 7 feature
        catch (Exception | Error e)
        {
            //suppresed exception
            e.getSuppressed();
        }
        System.out.println("Hurray1");
        try
        {
            this.method2();
            System.out.println("Hurray3");
        }
        // Need to either handle exception or propogate exception, only finally will not suffice
        catch (ClassNotFoundException e)
        {
            e.printStackTrace();
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
        // can catch a error too but not a good practise
        catch (Error e)
        {

        }
        catch (Throwable e)
        {

        }
        // finally should be at the end of all catch
        finally
        {

        }
        //Perfectly valid without catch clause, when try is empty or has method which throws RTE
        //try
        //{
        //}
        //finally
        //{
        //}
        System.out.println("Hurray2");
        // just like runtime exception need not specify
        throw new Error();
    }

    // Make throw different exception which is higher in hierarchy
    void method2() throws Exception
    {
        throw new ClassNotFoundException();
    }

    // method may thow multiple exception
    void method3() throws ClassNotFoundException, InterruptedException
    {
        throw new ClassNotFoundException();
    }

    void method5() throws ClassNotFoundException
    {
        throw new ClassNotFoundException();
    }

    // cannot throw exception if superclass doesn't declare
    //    public void method6() throws FileNotFoundException
    //    {
    //
    //    }
}

class Main1 extends Main
{
    // even static method is overriden, however usually we associate static method with class name
    // and do not show it as overriden
    public static void main(String[] str)
    {
        System.out.println("Main1");
        java.nio.charset.Charset charset = java.nio.charset.StandardCharsets.US_ASCII;
        java.nio.file.Path outputFilePath = null;
        try
        {
            outputFilePath = java.nio.file.Paths.get(new URI("name"));
        }
        catch (URISyntaxException e)
        {
            e.printStackTrace();
        }
        // j2se 7 feature try with resources - AutoClosable interface
        try (java.io.BufferedWriter writer = java.nio.file.Files.newBufferedWriter(outputFilePath, charset, null);)
        {

        }
        catch (IOException e)
        {
            e.printStackTrace();
        }
    }

    /**
     * Constructs a new Main1.
     */
    public Main1() throws ClassNotFoundException
    {
        super();
    }

    // overriding method cannot throw exption higher in hierarchy that is defined by super class 
    void method2() throws ClassNotFoundException
    {

    }

    // overriding method may chose not to throw exception at all even if super class 
    // method is throwing, can throw differnt exception.
    void method3()
    {
    }

    // Sub class cannot throw exception which is not thrown by superclass or
    // not in hierarchy of class.
    //    void method5() throws FileNotFoundException
    //    {
    //    }
}

Eclipse IDE tips

I started my career programming in c and assembly languages. It was only later after few years I switched over to java programming. I used to use Netbeans initially, but there was something about eclipse that I fell in love with.

Step 1:
Download and install eclipse IDE from link below.
http://www.eclipse.org/downloads/

Step 2:
Tweak the [Eclipse Home]/eclipse.ini if needed:
 
 -startup
 plugins/org.eclipse.equinox.launcher_1.2.0.v20110502.jar
 --launcher.library
 plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.1.100.v20110502
 -showsplash
 org.eclipse.platform
 --launcher.XXMaxPermSize
 --launcher.defaultAction
 openFile
 -vmargs
 -Xms40m
 -Xmx768m

Step 3:
Tweak the Eclipse preferences.

Sunday, July 3, 2011

irc freenode

freenode.net irc is one of the important place to discuss and learn about open source software projects. One must have irc chat client such as pidgin to connect to the chat rooms hosted by freenode.net.

Follow these steps:
1. Create a user account, server being irc.freenode.net
2. To register, message /msg NickServ REGISTER
3. For help on commands, message /msg NickServ help
4. After registration, one would receive an email for verfication
5. Message the verification code, eg: /msg NickServ VERIFY REGISTER
6. Upon verification, one can fetch the rooms listed upon server and join in.