2013年9月28日土曜日

Setting up a PC to run Linux/Fedora while keeping Windows install




Task 1 Prepare a USB drive with Fedora installation source

Why?

We need a media that contains Fedora on either CD/DVD or USB thumb drive. I chose USB drive since I have several old USB drives with smaller capacity sitting around at home.

How big should USB drive be?

Fedora 19 installation files is 951 MB. I used 2GB USB drive.


How do I "burn" Fedora installation image to USB drive?


You need to run a program called "USB Live Creator" which is available here.


Once you finish installing USB Live Creator, start the tool.


  • Select an appropriate Fedora image from "Download Fedora" drop-down
  • Insert your USB drive to your PC, and then select it at "Target Device" drop-down

(Press "Refresh" icon as necessary)


Once finished, you have an USB drive from which you can boot up a PC with Fedora.

Task 2 Parepare a USB drive with a partition tool

Why?

In order to keep your existing Windows OS, I need to free up my C: drive on my notebook computer.

I used a tool called Gnome Partition Editor (or Gparted for short). To use Gparted, you need to prepare a media with Gparted on it. I chose yet another USB thumb drive for that (but you can burn a CD too).

The size of Gparted is about 160MB. I have another 1GB USB drive that is used for anything useful at home (I bought this USB drive long time ago, paid $200 dollars back then, thinking it is a good investment! Now the price is so cheap that this is just a junk in my shoe box, but it now has some good use!)

How do I create a USB drive with Gparted?


I used a tool called "Tuxboot", which is available at SourceForge.

Once you download and lunch tuxboot,

  • Select "gparted-live-stable" under "On-Line Distribution" drop-down box (try "gparted-live-testing" if something goes wrong. I had to do that)
  • Select "USB Drive" at "Type:" drop-down.
  • Select an appropriate drive pointing to your USB drive.




Task 3 Prepare your hard drive with free partition

How to reboot using Gparted?

  • Shut down your PC
  • Insert your USB drive into a USB socket
  • Start your PC
  • While the machine is starting up, hit F12 to go to boot menu (NOTE: this key depends on you machine. Carefully watch the initial screen and look for "Boot menu")


At the boot menu, choose USB drive from the list of boot device 



Then, let Gparted start. Provide answers to a series of simple questions. Eventually Gparted user interface shows up.

How to shrink the Windows partition to free up space

With Gparted user interface, you can easily shrink a partition: use mouse to re-size, or punch in a number. As for the size, I chose to simply cut my 500GB drive into half: one for Window and the other for Linux.

How to reserve a primary partition for /home directory (Optional)


You can have an independent partition to be mounted as /home directory so that whenever I need to re-install Linux, I don't lose my data and some applications.

I created a primary partition of 100GB in size. The remaining free space will be used for other part of Linux installation.

Note that this step is optional. If you don't care, just leave the half of the HDD as "free"..

Here is the final state of my C: drive before I quit Gparted.


When you are happy, shut down the machine, and un-plug your USB with Gparted on it.


Step 4 Install Fedora using the USB drive

We will be using the USB drive, which contains Fedora, we created earlier.


  • Remove Gparted USB drive, if its still there
  • Insert the USB drive with Fedora into an USB slot
  • Restart your machine
  • Hit F12 to go to boot menu, then select USB drive.
  • Let Fedora OS to load.

Once Fedora is loaded from USB drive, you will see this choice. Choose "Install to Hard Drive"



Follow instructions. Everything is straightforward, except maybe the part where you configure disk storage.

How to mount my 100GB partition for /home directory


While configuring storage/partitions for Fedora install, I need to tell the install to use my 100GB partition to be mounted to /home

First, select a partition that corresponds to the 100GB partiion. In my case, it is listed as below.


Then, look at the right hand side pane. You can specify "/home" under "Mount Point:" field.



Configure other partitions


I followed information described in Fedora Recommended Partitioning Scheme to set up other major partitions such as /boo, root (/), swap, etc.

My final partitions look like this.



Complete Fedora installation

You need to at least provide a password for super user. Once done, just continue with the instructions.

You are done!

2013年9月19日木曜日

Setting up a HelloWorld Java project with Git and Jenkins under 5 minutes

What is assumed

  • Java is installed
  • Git is installed
  • Jenkins is installed

1. Create a HelloWorld java program



$ mkdir hello


$ emacs HelloWorld.java (or Notepad HelloWorld.java on Windows)


public class HelloWorld {
  public static void main (String[] args) {
    System.out.println("Hello World !!");
  }



$ emacs run.sh (Let's create a script to compile and run. Its Notepad run.bat on Windows)


javac HelloWorld.java
java HelloWorld


$ run.sh (execute the script you just created. Its run.bat on Windows)

2. Create a Git repository for HelloWorld source



$ git init


$ git add HelloWorld.java run.sh


$ git commit -m "created"


$ git log

3. Create a Jenkins job to get latest code from the Git repository and then build and run HelloWorld project



1. In Jenkins, bring up "Manage Plugins" screen




2. Make sure that Jenkins GIT plugin is installed. If not, install it.




3. Create a new Jenkins Job.



Name this job "git_test".


4. In the job configuration page, choose Git for "Source Code Management" and then set "Repository URL" point to your Git repository.




To figure out a string to put in to "Repository URL" box, see my local path to the Git repository can compare with you environment.

[tsuyoshi_watanabe@ywatanabe hello]$ pwd
/home/tsuyoshi_watanabe/sandbox/gittest/hello


5. Add run.sh script as a new build step





4. Putting all together

Choose "Build Now" for our newly created job.






Now, Jenkins hit our Git repository to clone a temporary source tree, and then execute our "run.sh" script.

2013年9月18日水曜日

Test publish a Jar file to your local Artifactory from Gradle build under 5 minutes

What you need:



What is assumed


  • Artifactory is installed at its factory default port 8081
  • Artifactory's pre-configured "admin" user's password is "password" (default)

Steps


1. Create a copy of Java Quickstart

2. Open build.gradle file and replace the content with the gradle script in the following:


buildscript {
    repositories {
        maven {
            url 'http://localhost:8081/artifactory/plugins-release'
            credentials {
                username = "admin"
                password = "password"
            }
        }
    }
    dependencies {
        classpath(group: 'org.jfrog.buildinfo', name: 'build-info-extractor-gradle', version: '2.0.9')
    }
}

apply plugin: 'java'
apply plugin: 'artifactory'
apply plugin: 'maven'

sourceCompatibility = 1.5
version = '1.0.2'
group = 'test.quickstart'

jar {
    manifest {
        attributes 'Implementation-Title': 'Gradle Quickstart', 'Implementation-Version': version
    }
}


dependencies {
    compile group: 'commons-collections', name: 'commons-collections', version: '3.2'
}

artifactory {
    contextUrl = "http://localhost:8081/artifactory"   //The base Artifactory URL if not overridden by the publisher/resolver
    publish {
        repository {
            repoKey = 'libs-release-local'
            username = "admin"
            password = "password"
            maven = true
            
        }
    }
    resolve {
        repository {
            repoKey = 'libs-release'
            username = "admin"
            password = "password"
            maven = true
            
        }
    }
}

3. At command prompt, run $ gradle artifactoryPublish

4. Verify that Quickstart.jar file is added to artifactory by checking localhost:8081

Done.

Yet another GIT tutorial under 5 minutes.

At your command prompt, type "git", Nothing happens? Please Google "How to install GIT" and come back.

Just keep typing the following and observe what happens. (This procedure is based on this blog).

Start at any junk directory/folder such as temp.

Start!


$ mkdir gittest


cd gittest


mkdir example.git


cd example.git


git init --bare


cd ..


git clone example.git example1


cd example1


$ emacs test.txt (use Notepad on Windows)


Type "hello" in test.txt, and then save and close notepad.


git add test.txt


git status 


git commit -a -m "new file added."


git status


git push origin master


cd ..


git clone example.git example2


cd example2


git log


emacs test.txt


Type "I am using GIT!" in test.txt, and then save and close notepad.


git status


git commit -a -m "added another line."


git status


git push origin master


cd ../example1


git log


git pull


git log


Done!


You have just simulated a typical coding cycles using any version control system.
  1. Created a new repository for the team
  2. A team member added a new source file (initial implementation)
  3. Another team member modified the file (bug fix)
  4. The first team member received the fix made by his buddy.

2013年7月18日木曜日

How to render JSON key-value properties using AngularJS

See a demo at JSFIDDLE


When you are developing REST API on server side, you sometimes want to have a page that renders JSON data in a bit nice way than a row JSON view (that most browsers do good job rendering, but still somewhat hard to read)

To render JSON data in a simple HTML table (or whatever) format with minimum AngularJS coding, here is how.


JSON Data

Let's say, you have a JSON data (this is from AngularJS Tutorial) available from a controller ("C" part of MVC)

function PhoneListCtrl($scope) {
    $scope.phones = [
        {
            "name": "Nexus S",
            "snippet": "Fast just got faster with Nexus S.",
            "age": 0},
        {
            "name": "Motorola XOOM with Wi-Fi",
            "snippet": "The Next, Next Generation tablet.",
            "age": 1},
        {
            "name": "MOTOROLA XOOM",
            "snippet": "The Next, Next Generation tablet.",
            "age": 2}
    ];
}

HTML markup 

...with AngularJS expressions. Note the expression "(key, value) in phone" below. (By the way, this is "V" part of MVC, and "phones" data is the "M" part, just for the sake of completeness!)

<div>
  <h1>Phones</h1
  <div ng-repeat="phone in phones">
    <h2>{{phone.name}}</h2>
    <table border="1px">
      <tr ng-repeat="(key,value) in phone">
        <td>{{key}}</td>
        <td>{{value}}</td>
      </tr>
    </table>
  </div>
</div>

Result

Phones

Nexus S

age0
nameNexus S
snippetFast just got faster with Nexus S.

Motorola XOOM with Wi-Fi

age1
nameMotorola XOOM with Wi-Fi
snippetThe Next, Next Generation tablet.

MOTOROLA XOOM

age2
nameMOTOROLA XOOM
snippetThe Next, Next Generation tablet.

2013年7月1日月曜日

How to run angular tutorial with IIS 7 or node.js


If you are a developer with Windows machine and want to play with AngularJS, here are the steps.

Downloading Angular tutorial

  1. Create a clone on your machine
    1. Go to https://github.com/angular/angular-phonecat
    2. Choose "Clone in Desktop" (This asks you to give permission to start GitHub windows client)
  2. Download a given "step" within the turoial
    1. Run "git checkout -f -step-0" (here 0 should change depending on which step you want)


    Running Angular tutorial using IIS

    1. Create a new test website
      1. Navigate to "Sites" folder
      2. Right-mouse click and choose "Add Web Site..."
        1. Name it "angulartest"
        2. Point to the directory where Angular tutorial web site exists
        3. Set Port value to 85 (or 86 or 8080, or whatever unused on your system)
    2. Configure permissions
      1. Right-mouse click on "angulartest" website and choose "Edit permissions..."
        1. Under "Sharing" tab, share the folder with "Everyone"
        2. Under "Security" tab, add "Everyone" to the list of users.
    3. Configure application pool for the test website
      1. In IIS, select "Application Pools"
      2. Select "angulartest" from the list
      3. Select "Basic settings..." from the Actions on the right hand side
      4. In Edit Application Pool
        1. Set "No Managed Code" to .NET Framework version
        2. Set "Classic" for Managed pipeline mode
      5. Select "Advanced settings..." from the Actions on the right hand side
        1. Set "NetworkService" at Identity property
    4. Run angular tutorial in a web browser
      1. Browse to localhost:85/app/index.html

    Running Angular tutorial using Node.JS

    1. Install node.js (just download an installer)
    2. Install http-server package
      1. Run "npm install http-server- g"
    3. Start web server
      1. CD into the root directory of Angular Tutorial
      2. Run "http-server -p85  (-p is to specify port)
    4. Run angular tutorial in a web browser
      1. Browse to localhost:85/app/index.html

    2013年6月30日日曜日

    Setting up angularjs on Windows 7

    My ultimate goal was to try out AngularJS, which supposedly gives us MVC in JavaScript world.

    For our game, which is written in .NET stack, I recently set up REST API and WebSocket, and about to embrace JavaScript-oriented browser client.

    Also, my colleague at work set up a web app (there, we use Java as the server) using YEOMAN.

    The world of JavaScript development is pretty alien to me. I've used JQuery and I know basic HTML5/CSS3 stuff, but not much more than that.

    This is just a log of what actions I've taken to get to the point where I have a AngularJS app running (probably integrated to ASP.NET MVC3 - or maybe side-by-side).

     Its work in progress so I may update this later.


    1. Installed Chocolately that gives us a mechanism to install all kinds of software, many of which we know and familiar with (but we use separate "Installers" to install it on Windows). Chocolately let you install at command line.
    2. I used Chocolately to install Yeoman as:
      1. cinst yeoman
    3. To scaffold a web app, this is the Yeoman command line I used, which worked
      1. yeoman init
    4. I was curious about other Yeoman command. One of them is "Yeoman list" to list all packages, but I run into an error:
      1. yeoman list
      2. Error Arguments to path.join must be strings
      3. I found an article that suggests a fix, but I could just not find the file to put a patch (even when I grepped the entire drive. I must be doing something stupid)
    5. I gave up and I decided to do clean install again. By this time, I realized that nodeJS's Node Plugin Manager (nmp) is the tool to install the tools that comprises YEOMAN, namely, yo, grunt, and bower. So I installed them one by one (I basically just followed the "installation" instruction at yeoman.io website.)
      1. npm install -g yo grunt-cli bower
      2. npm install -g generator-webapp
    6. At this point, I believe I have all the tools I needed, some were installed as part of Chocolately install, some other manually by hand. Verify this by just obtaining version number of each tool
      1. node --version
      2. git --version
      3. yo --version
      4. grunt --version
      5. bower --version
      6. ruby --version
      7. compass --version
    7. Once I got these tools installed, then I proceeded to generate AngularJS project (again, just follow "Usage" instruction at yeoman.io website.)
      1. npm install -g generator-angular
      2. yo angular
    This is as far as I got. AngularJS project has been created but I see bunch of errors too and not sure if they are show-stopper or not.

    2013年6月7日金曜日

    android.bat doesn't start up on Windows

    Goal

    I want Android SDK Manager to show up!



    The problem

    Console opens up for a split second, but closes immediately. If you run it from CMD command-line, you receive an error saying:  android.bat 'C:\Program' is not recognized as an...

    Yeah, its yet another stupid "Program Files" folder related problem on Windows...

    Fix

    Make a copy of the original android.bat to something like android.bat_original
    Open android.bat in a text editor
    Look for a line that says: call lib\find_java.bat









    Comment out call lib\find-java.bat line


    Then add a full path to your local java.exe, within a pair of double-quotation marks.









    That should work.

    Details

    "sdk\tools\lib" folder contains an executable file called find_java.exe. This little program seems to be working just fine. It figures out the correct full path to java.exe (and javaw.exe if you give -w switch).

    "sdk\tools\lib" folder also contains find_java.bat script file, and this is the batch file we commented out above. This guy seems to have issue handling a white space in "<Drive>:\\Program Files\Java\....". Rather than trying to figure out how to make CMD batch file to work (which is a major pain), I recommend just set java_exe environment variable explicitly as shown above.


    2013年5月24日金曜日

    How to parse .NET DateTime Ticks value in Java

    I had to consume an XML data that contains .NET DateTime Ticks (long type) value. This should do it.


    import java.util.*;

    public class DotNetTicksUtil 
    {
      
        private static final long TICKS_AT_EPOCH = 621355968000000000L;
        private static final long TICKS_PER_MILLISECOND = 10000;

        /**
         * Given a .NET ticks value, we convert it to Java's Calendar object.
         * Conversion may not be perfectly precise, so do expect some margin of errors.
         */
        public static Calendar toCalender(long ticks) 
        {
            //long ticks = 634200192000000000L;

            Date date = new Date((ticks - TICKS_AT_EPOCH) / TICKS_PER_MILLISECOND);
            System.out.println(date);

            TimeZone utc = TimeZone.getTimeZone("UTC");
            Calendar calendar = Calendar.getInstance(utc);
            calendar.setTime(date);
            return calendar;
        }
    }

    2013年5月22日水曜日

    Note to myself: Creating a self-installing .NET Windows Service

    (This is not about Java. Its about .NET)

    It took me while to get it working, so I am writing a note to myself for future reference.

    • In Visual Studio .NET IDE, do "Add -> New Item..."
    • Select "Installer Class"

    Your new installer class is added to your project. Next, we want to add ServiceProcessInstaller and ServiceInstaler from the Toolbox but you won't see them in the Toolbox by default.

    To make these two components to show up:

    • Right-mouse click on Toolbox and select "Choose items..."
    • Look for these components and select them.

    Both SeviceProcessInstaller and ServiceInstaller components will show up in the Toolbox, so drag them to the Installer's designer.

    Select each item on the designer and F4 to show its properties and configure them (Google to learn details about  what to set)

    That should do.

    Earlier, I tried to create an Installer class manually without using IDE designer and I ran into too many weird issues. Then, the designer approach worked in two minutes.

    2013年4月18日木曜日

    If you are a C# developer who doesn't use LINQ feature, then you should.

    Java doesn't support LINQ type of query syntax against collections.

    If you are an old timer C# developer who hasn't really started using LINQ (hard to imagine anyone not using it by now), then you are missing out a big productivity boost.

    Programming in Java everyday makes me realize how useful it is.

    The same thing can be said about these C# feature:

    • using syntax to create alias of a class name to in case of namespace crash (e.g. two classes named the same and used in the same context)
    • Event (I mean EventHandler<T> and += stuff)
    • Lambda expression (=> stuff that allows you to create piece of implementation in line)
    • Anonymous class (a way to create a structure on the fly) - super useful for passing a simple data structure without creating class (prevents class explosion)


    These are C# feature I miss the most.

    2013年3月30日土曜日

    Exactly two months with Java

    So, it has been exactly two months since I became a professional Java developer. (I have about 10 years experience in .NET and C#)

    Actually, my work involves dealing with some .NET applications so I am not 100% pure Java developer, but still the team I am part of is nearly 100% Java developers.

    I like to share my experiences so far.

    Java language
    Of course, two months is not long enough for me to see all of the major aspects of any language, but being similar to C# in terms of syntax as well as how it runs in a managed memory environment (virtual machine), my knowledge in areas such as .NET Reflection, IDisposable, generational garbage collector, design patterns, exception handling, all help.

    Java syntax
    I won't cover the syntax war such as where to put the curly braces. I just follow team's convention so it doesn't bother me, but it does take some getting used to.

    Exceptions
    This is annoying. Java is more strict about exception potentials. If a method has a potential to throw an exception, you either have to handle it or declare it as part of the method signature. I prefer C# on this where it does't require you to declare it in the signature. Seems this is too much work.

    Extends and Implements
    In Java, if you implements an interface, you have to say implement and if you extend a class, you have to say extends. Makes sense. However, I liked C#'s simple syntax of ':', but this is something you can get used to quickly.

    LINQ
    I miss it! Java has nothing like that.

    Iterators
    In Java, you use "for" with a special syntax that involves a semi-colon. In C#, you use "foreach". I like kind of like Java syntax too.

    Events
    I miss it in C#. There are no intrinsic notion called Event in Java that supports publisher-subscriber design pattern. As you know, in C# you can declare an event with EventHandler and have clients do += to subscribe to it. Very simple and neat. Java doesn't have that, and you pretty much have to pass a callback interface and have the event source object to "call" the handler. (I don't know if Java has delegate/functor.. does it? If so, you could pass delegate - still new on this)

    Eclipse
    OK, where do I start with Eclipse... I have so many things to say about this IDE.

    Visual Studio vs Eclipse?
    I would have to say that Visual Studio is better in the following aspects:

    • Visual Studio is so much faster to load. Period. Even Eclipse-classic, which is the bare-minimum feature set to do vanilla Java development can sometimes spend minutes to load.
    • Visual Studio provides nice feature packaging. In this regard, Visual Studio is like Apple product. You pick an edition from a few choice, and you live with what it comes with (well, there are extensions these days so not true but for most part you are all set once you install a Visual Studio). With Eclipse, you have to either work with EE package which is bloated with lots of feature that you might never use and deal with slowness during both start up time and during use. Trust me. EE was so horribly slow that I set up ProcessMon to see what it's doing, and it was reading ton of files for plugin stuff, taking like 10 minutes in response to a menu item. Its horrible.
    • Visual Studio is much more stable. Back in .NET days, I might have had three instances of Visual Studio running for several months. With Eclipse, I probably forcibly killed Eclipse process (which also creates java.exe and javaw.exe processes on top of eclipse.exe process) maybe like 50 times. It happens less after I built a lean-and-mean Eclipse created from bare-minimum Eclipse classic. Maybe Eclipse appeared hung when it was just working on something. But I couldn't tell and I lost many hours just waiting for it to complete its jobs. Its horrible.

    Now, there are nice things about Eclipse too. I haven't come to appreciate it much but I see some potential, and its extensibility.  Feature set is not dictated by a single company. Its built by a community. Writing your own plugin (extension module) is easy - it even came with a tutorial right within Eclipse.

    So, Eclipse is much more flexible, but that flexibility also implies complexity and lack of uniform testing of the products. You have to tame it.

    Some surprises for Visual Studio users
    You have .sln for Visual Studio. Eclipse doesn't have one. Instead, it uses a "folder" which is designated as "workspace". Its very file system oriented.

    Namespace hierarchy and file system hierarchy must match. This is Java characteristics. I am so used to be able to put my .cs files at any folder organization, when you see com\company\product\foo\bat\hello.java (and usually deeper than this), you are like "oh crap, do I have to dig deep into this folder structure everytime I wanna open a .java file? (By the way, you don't. If you use Eclipse's Package Explorer, you can get to each .java class directly)

    In Visual Studio, .csproj keeps track of the membership of source files. If you have a junk .cs file in your project but if its not part of .csproj then it doesn't matter. Its not part of the project. In Eclipse, it is part of your project. Its file based. If a file is in the folder that contains source, then it is subject to build.

    Maven
    Maven was very confusing to me at first, but after going through some tutorials it makes sense and it is a nice build system. I don't have much experience with Ant (but have done Nant and MSBuild) but many Java programmers seem to appreciate Mavan in terms of ease of use compared to Ant.

    Its concept of repository is very powerful. Its very open-source oriented in the sense that you have a gigantic repository of stuff people build and you build your project by using those in the repository. Your project itself can be part of the repository. Its a wonderful open-source reuse mechanism.

    Also dependency management becomes easier as you don't have to be aware of the hierarchical dependency tree. Maven will take care of downloading all needed for you.

    I like it. I am not aware of .NET counterpart for this.

    I tried to use Maven's POM file (its Maven't project file, if you will) with Eclipse using a special plugin just for that. It didn't work for me (but its due to the projects' complexity and my lack of understanding on my part). But once I gain experience with Maven Eclipse plugin, I would probably prefer to use Maven POM over Eclipse's native .project and .classpath file. (These are kind of similar to Visual Studio's .csproj but not quite


    JBoss
    This is just one of the web server. Its quite different from IIS. Like many open-source applications, you don't have a Setup.exe for this. You just un-zip a bunch of files to a location you like, and done.

    It comes with script (both .sh and .bat for Linux and Windows). I use Cygwin and .sh files but you can easily use CMD to use .bat and do the same thing. To run a server (like IIS's "start"), you open up a console and run an appropriate batch file to start it.

    Once you start it, then you would use brower to interact with an administrative page. This is very different from IIS where there is a Windows interface to work with various IIS configurations. You can use JBoss web admin interface to add "application" by pointing to a .WAR file (a zipped up web application content). You could also use file system based deployment of your web application by placing a set of web application files under a special folder called "deployments" and then place a so-called marker file in there. JBoss has a built-in scanner that watches this folder and takes a presence of a marker file as a command. Kinda weird and feels like 80ish way, but it works.

    PostgreSQL
    Our team happens to use this. I just thought this is nice database. I have been using Microsoft SQL Server but I can see myself using this instead of SQL server. It provides a nice UI to manage database. I haven't had chance to work with this extensively yet but so far it seems a very nice easy-to-use database.

    Hibernate
    This is a counter-part of .NET ADO.NET Entity Framework. I don't have extensive experience with this either but it seems to have nice infrastructure to define mappings between your class and database schema. I love Entity Framework, but it has some learning curve. I like to see how easy Hibernate is as I think there is a .NET package of hibernate.

    OK, maybe that's it.

    So far, I am enjoying working with Java and open-source server applications.

    2013年3月15日金曜日

    UML Modeling Tool for Eclipse

    I want boxes and lines to describe the classes.

    I could use:
    • Microsoft Power Point (I prefer not)
    • Microsoft Visio (I prefer not either. Its not even installed on my machine and am too lazy to find a copy licensed to the company I work for)
    • Google Presentation (My favorite choice for general diagramming, but its not a modeling tool)
    Well, since I am in this wonderful open-source Java/Eclipse land, there got to be a nice free modeling tools out there.

    There seems to be a lot of tools offered out there, and I am very much confused (e.g. there are UML2 SDK, some Graphical modeling tool, and Ecore, and some commercial versions?)

    Anyway, I found one that's sufficient for my needs. The choice I made is Eclipse Modeling Framework (EMF). Actually, there is already a nice tutorial article about EMF.

    This is what I did:

    First, made a new copy of Eclipse specifically to have modeling related plugins (I wanted to avoid adding too much stuff for feature that may not be used all of the time)








    Then hand-picked a couple of items (used the tutorial article I mentioned above).

    Now, I can create UML-like class diagram.

    I heard that you can generate Java source from the model. I haven't tried it yet but I am sure that would be useful. For now, having a UML-like tool is good enough for me.

    TIP: I usually use the light-weight Eclipse class with few server-related plugins. That instance can't handle EMF files - it just shows the content of .ecorediag as plain XML file. That's fine. Only when I need to interact with it in graphical editor, I start "model" version of Eclipse.

    2013年3月14日木曜日

    Lean and mean Eclipse

    I download Eclipse IDE for Java EE Developers JUNO (4.2).

    It sucks. Its very slow and sluggish. It is unusable for me. Eventually I leaned that increasing the memory for JVM helps, but its still slow.

    I noticed that Java EE package has a ton of plugins, some of which I care less.


    If you compare packages, the Classic package seems to be a good baseline to start. So I decided to start all over with Eclipse Classic as the baseline, and gradually add feature to it.


    The Classic package loads quickly and stays very responsive. The way it should be!

    Now, I like to do these things with my Eclipse instance:

    • Edit XML files
    • Create web projects
    • Work on JSP and Servlet stuff
    • Work on HTML, CSS, and JavaScript
    You can do these things if you install Web Tools Platform

    At first, I thought there is a single package called Web Tools that contains all of these, but it seems that's not the case. So I manually picked half a dozen plugins that are part of the Web Tools Platform.

    Here is how to add then.

    First, choose "Install New Software..." menu.


    Pick "juno" as a software site.


    Expand "Web, XML, Java EE and OSGi Enterprise Development" node.
    Then pick those items shown below.



    Done. You see Web Tools Platform added..



    Eventually, I will want to add Subversion, Maven, and JBoss related plugins, but I want to do that one at a time.

    Happy coding in Eclipse now!

    2013年3月9日土曜日

    Eclipse IDE is slow

    To speed up Eclipse IDE, you need to edit eclipse.ini, which is right where eclipse.exe is located. Go to the bottom of this article for the settings I have.


    You would want to make sure that following lines are in it.


    -Xms512m
    -Xmx1024m
    -XX:MaxPermSize=256m


    Background

    I have to use Eclipse IDE for the job I took 6 weeks ago.

    Fine. So I go to the Eclipse web site.

    It looked like there are a bunch of pre-configured packages for Eclipse, depending on what you indent to do with it. Since I am expected to do lots of server side stuff, Java EE seemed the right choice for me. So I downloaded it and installed it (which just involves un-zipping the entire contents to an arbitrary folder - a surprise to a .NET developer like me)

    I never really used Eclipse before, so I wasn't ready, but the first impression I had was "holy cow, its so slow!" It was sluggish, non-responsive, and every time I did almost anything, it took like few seconds to sometime few minutes, not kidding! (Note, the machine I was given had 24 GB of memory with Xeon processor).

    For example, when I switch my tab to view an XML file, it took like few seconds for it to show the content. When I did a right-mouse click on a Java editor, it look like a few seconds to show the menus. I probably killed the Eclipse (and its associated java process) several times using Windows Task Manager when I was staring at Eclipse splash screen for a couple of minutes. It was just not usable.

    So, I Googled and found out that basically the default Eclipse IDE configuration is too conservative about its memory use, in terms of JVM (an equivalent of .NET run-time). 

    There are lots of recommended configurations out there, but having these lines that mentioned earlier did the job for me.