The Source for Java Technology Collaboration
User: Password:



Bruno Ghisi's Blog

Bruno Ghisi Bruno Ghisi is a Java enthusiast with focus on Java ME, open source and wireless technologies. He is a Mobile & Embedded Community Star and Java Champion. In addition, he helps a JUG called GUJava/SC and maintains some open source projects, such as Marge. He is a new grad that intends to do a Master and currently works for CERTI Foundation. Also, he lives in an island in the south of Brazil called Florianópolis.



Why do we write open source code?

Posted by brunogh on June 17, 2008 at 08:55 PM | Permalink | Comments (12)

For some time I was thinking about writing this post and I have just watched Chris DiBona presenting a fantastic session called Open Source is Magic in Google I/O and got motivated. In addition to this, today is Download Day (if you have not downloaded Firefox 3.0 yet, go ahead and do it), so nothing better than write about open source on this Tuesday.

I was deep thinking why people write open source code. I am not talking about why companies do it, I am talking about you, as a developer, do it in your free time. According to a very interesting BCG/OSDN Hacker Survey made in 2002 - I could not easily found it, so Chris got me a copy (thanks!) - it could be extracted 4 groups from the different motivations answered by the public: believers (do it because they think open software should be open), professionals (for work needs and professional status), fun seekers (for non-work need and intellectual simulation) and skill enhancers (for skill improvements).

[Updating] The motivations that made the groups:

I can understand this group segmentation, but I think the time has definitely changed and we - communities, companies and softwares - have definitely evolved. Some years ago, Java was not open source, Firefox and OpenOffice.org were getting more adopters, Ubuntu was not out, companies were not doing contests and giving prizes away, etc, etc, etc. But my big question is, why do you write open source code? I mean, why do you join, for example, java.net, SourceForge, Google Code or freshmeat and commit your code there in order to create a whole community around it? Why do you send code to help a current open source project? Answering this question, I would say that I am a believer because I do it for the knowledge sharing between people, but I definitely do it for the fun too. How fun is sharing your ideas, getting new ones, mixing all together and creating something even more nice?! Talking about fun, would you will invite someone to go out for a glass of water on Friday night? Neim! It is the same as wasting your free time to write something that you do not get excited, it just does not make sense.

So, it is your turn. What do you think about the current period that open source is passing? What do you do for open source and why do you do it? Any other comments you may have, please feel free to add!

PS: I was looking some other presentations in Google I/O and there was a slide showing the book Producing Open Source Software from Karl Fogel. I have read this book some time ago and it has a pretty interesting reading if you want to learn about the nature of maintaining an open source project. Take a look!

Cheers,
Bruno Ghisi



Playing with Mobile Sensor API, Marge and JavaFX Script

Posted by brunogh on June 10, 2008 at 09:05 PM | Permalink | Comments (5)

I am disappointed... I could not go on with my tests envolving phoneME Advanced on iPhone due to iPhone SDK just runs on Mac OS X. Boring week, I bought an iPhone for that and someone thought everybody should have a Mac OS X to use it... what a nice thing! Anyway, let's change plans for now... I found something funnier: let's play with JSR 256 (Mobile Sensor API or MSAPI). But let's use Marge (Bluetooth) and JavaFX Script too!

MSAPI in NetBeans

The current Wireless Toolkit, 2.5.2, does not support MSAPI yet, so you need to make some tricks.

First: Download the JSR 256 RI. If you do not have a Forum Nokia account, go ahead and make one. Unfortunately, it seems the zip is packed for Windows due to the .bat and .exe files inside, but it looks that it is just script files, so probably works on other OS if you adapt.

Second: I suppose you already have NetBeans 6.1 with Mobility Pack, so let's add a new platform into it. Go to Tools->Java Platforms->Add Platform...->Select Java ME MIDP Platform Emulator->Click Next->Select the folder you have extracted the downloaded zip and advance until the end. If everything went well, you probably got a new platform called Prototype 2.0 S60 MIDP Emulator. Great! You are now able to create and compile applications that uses MSAPI specification.

We are not going to emulate the sensors, but if you want, go ahead and start $RI_PATH/tools/simulator/bin/start_sensorSimu.bat.

Starting with MSAPI

From the specification:...it allows Java ME application developers to fetch data easily and uniformly from sensors. A sensor is any measurement data source. Sensors vary from physical sensors such as magnetometers and accelerometers to virtual sensors, which combine and manipulate the data they have received from other kinds of physical sensors. Examples of virtual sensors could include, for example, battery level sensor indicating the remaining charge in a battery, or a field intensity sensor that measures the reception level of the mobile network signal in a mobile phone. The sensor may be connected to the mobile device in different ways, represented by the connection type, examples of which are embedded, short-range wireless, wired, and remote connection type.

The classes and interfaces of this API are defined in the package javax.microedition.sensor.

To start playing with sensors, basically you need to find them in order to get a the SensorInfo references. There are two static methods in SensorManager for that: findSensors passing the sensor url and the overload one passing the quantity and the context of use (if you set null for both parameters, all the supported sensors will be returned). From our demo application:


SensorInfo[] si = SensorManager.findSensors("acceleration",
  SensorInfo.CONTEXT_TYPE_USER);

After that, you can connect into the sensor using the well known Generic Connection Framework (GCF):


String url = si[0].getUrl();
SensorConnection sensor = (SensorConnection) Connector.open(url);

Then, you can start collecting the data. There are two ways of collecting the data in MSAPI: synchronously and asynchronously. In the first, you have to call SensorConnection getData iteratively. In the asynchronous way, you have to register a DataListener, invoking setDataListener and passing a reference of it and a buffer size (this number will be determine the data collecting frequency), that will be responsible for calling the dataReceived method. This method will return the SensorConnection reference, an array containing the data channels (for example, for a 3-axis accelerometer, the array will have length 3) and usually the last parameter will be false when the listener handles the data quickly:


sensor.setDataListener(new DataListener() {
  public void dataReceived(SensorConnection sensor, Data[] data, boolean isDataLost) {
    ...
  }
}, 10);

Our demo: Bluetooth Sensor FX Tetris

The demo of this post is pretty simple. I got the Bluetooth JavaFX Tetris Game and changed the way of interaction. You do not have to type the direction in your mobile anymore, you can now use its accelerometer. Avoid typing, you can get a RSI (Repetitive Strain Injury)! Basically, I have implemented the dataReceived method to process the data collected and send over Bluetooth to the game. It is still missing some better balance in the accelerometer as you can see, but works as a proof of concept.

The code of JavaFX Tetris Game (BluetoothJFXTetris) is under Marge's Demos repository as well as the MIDlet controller (genericbtsensomapper-mobile). Go ahead and checkout them! They are open source! I have tested this demo with my designer friend' Sony Ericsson K850i and worked... as a demo, off course! I have noticed that sometimes the game crashes, I am not sure yet why, but I suspect that is something related to threads and rendering.

Here is a terrible preview video. It was recorded using the phone mentioned in the beginning of the post, probably I will have to record it again, but I could not wait until tomorrow to post about this experiment:


Thanks to Raghavan Srinivas that pushed me up to work on this demo during our fast talk at JavaOne! Cheers!

Have a nice week! :)
Bruno Ghisi



First steps with iPhone and Java...

Posted by brunogh on May 25, 2008 at 09:49 PM | Permalink | Comments (9)

When I was at JavaOne, I sold my soul to devil: I bought an iPhone. Here in Brazil, there is no iPhone being officially selled yet.

Let's start having fun and playing with Java on it:

  1. Unlock your iPhone. Babies can do that before they say mama. More information at Zibri's Blog.
  2. Make it useful: Install Cydia (front-end for Debian APT) to substitute default Installer application. In Installer, go to the Source option, click Edit, Add http://apptapp.saurik.com, Done and then Refresh. Then go to Install option, search for Cydia Installer and install it.
  3. After that, open Cydia and search for the word Java, there are a few stuff part of the iPhone/Java package available in Development menu. You are able to make graphical applications using the UI Framework, which is possible due to JocStrap, a Java/Objective-C bridge. Install iPhone/Java that will bring the necessary stuff (JamVM, etc) for this simple demo. Also, later try to install Jikes, a compiler for version 1.4 and fastjar, an alternative for running jars, because I could not test them yet.

PS: Install OpenSSH in your iPhone and then connect your laptop on its server. Also, install Boss Prefs to be able turn SSH on/off. Finally, do not forget to change you root password using passwd, default password is alpine.

I have created a simple Hello World app into NetBeans. Then I have compiled it, tranfered to iPhone and runned (via SSH).

Code:


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

Screenshot:
java_iphone.png

Community will bring ME world into iPhone as well. The answer for this is phoneME Advanced. Keep and eye and join the mailing lists! As you can see, there are some very nice projects going on!

Have a nice and funny week!

Bruno Ghisi



LWUIT is the way!

Posted by brunogh on May 18, 2008 at 05:49 PM | Permalink | Comments (0)

Forget about what I have said previously, LWUIT (Lightweight UI Toolkit) is the way!

LWUIT was launched at JavaOne 2008 and there are already some nice tutorials and demos about it. I met some of the guys in the Pavillion and I was impressed with the lib, very cool! Another point is that you can also use LWUIT in commercial applications, it was released under the SLA.

Picture49.png

LWUIT is a UI library that is bundled together with applications and helps content developers in creating compelling and consistent Java ME applications. LWUIT supports visual components and other UI goodies such as theming, transitions, animation and more.

Don't waist your time drawing Canvas, take a look on it!

Bruno Ghisi



J1 is awesome!

Posted by brunogh on May 13, 2008 at 08:52 PM | Permalink | Comments (0)

There is no word to describe what is JavaOne. If I take a try, I would say that is definitely awesome! It rocks! It is the best geek tourism ever!!!

The sessions are great, the speakers are great, the Pavillion is great, the communities, companies, people, all the information, flyers, talks, contests, chats, demos, videos, places, souvenirs, stuff, food, parties, pubs, dinners... the coolest people from the whole world speaking about Java and whatever runs in a JVM!

I will not describe all the sessions and things I have seen, because I could easily write a few of books about it. I suppose everyone have seen different JavaOnes, due to the many information in its atmosphere and because we cannot split ourselves in time... So, I have added some pics that show much more. Follow them to see what happened with me, probably not in this sequence, but I can't remember, I spent a whole week as it was a day! Too much fun!

And the fun was just starting...

...do you know that people are the center of everything that happens?

...I mean, because of a lot of people, all those things happens...

...yes, a lot of... and in everywhere, the Pavillion was awesome to meet them...

...and those people play video games when they are tired... or sometimes just rest...

...you can meet those people in a Smash Mouth concert... who does not like rock?


...I met Aaron Houston there... is he Brazilian?!

...he took me to a cool JavaPosse session... very informal and funny, as you can see...

...then I got my car and it drove me ti the next pub...

...yeah... definitely everybody likes rock!

...a lot of Mobile and Embedded people were there!

...Have you seen all the cool demos we got?


...after some pints, I think I was in Mars...

...and then I encourage myself and got a Marge Duke tattoo...

...I can't remember the rest, but I wake up with Neil Young in the stage... wow...

...then I just discovered that Jonh Cage is Brazilian too... he said don't be shy!

...yes... I tried...

...so, James Gosling just appeared in the CommunityCorner...

...and all his fans liked that!!!


...too much things going on... time to rest, let's watch a movie...


...everybody would be tired after a day like that, don't you think, Roger?

As 24Hrs (do you know Jack Bauer?) episode would say, the following take place between 5th of May and 9th of May... something like that, I cannot remember the hours exactly...

Great to meet everybody and be part of this! It was my pleasure! I got addicted to JavaOne!!!

What a busy day!

Thanks,
Bruno Ghisi



Marging a FX Tetris at JavaOne!

Posted by brunogh on April 27, 2008 at 06:10 PM | Permalink | Comments (11)

Marge (Java Bluetooth Framework) got a mini talk in Community Corner. It will be on Wednesday at 3:30 pm. If are you interested in Bluetooth, JSR 82 (Java Apis for Bluetooth) and Marge, do not miss that! We have integrated a Bluetooth mobile controller for a nice James Weaver's compiled JavaFX Script tetris game! Thanks, Jim!

Here is a preview (updated):

The old video is at http://www.youtube.com/v/ZvVx6RGjCjM

It will be easy to find Marge:

margeinthebackpack.jpg

Here is the last tip, keep an eye on the Mobile and Embedded Wiki page for JavaOne!

I am very excited to meet new people! See you in San Francisco!

Bruno Ghisi



Pics from fisl 9.0

Posted by brunogh on April 22, 2008 at 09:40 AM | Permalink | Comments (0)

The 9th edition of fisl (International Free Software Forum) was huge! 7417 participants from 21 countries talking about open source 12 hours by day during 3 days. Wow! Great atmosphere! Great sessions! Great people! Great ideas, discussions, dinners...

Here are some pics that I got from my terrible camera:

1.JPG
Ale Gomes, from Mobile & Embedded, and Fabiane Nardon, JavaTools Community Leader.

2.JPG
Bruno Souza, Javali, Brazilian Sun Ambassadors, OpenSolaris User Group... did I forgot anyone?

3.JPG
Marge checking out a mobile session with her MSA compliant device!

4.JPG
Lucas Torri, Roger Brinkley and I. Sorry model agencies... no runways, we are busy....

5.JPG
What a nice guy!

6.JPG
Roger Brinkley, Mobile and Embedded Community leader, playing golf during his cool session!


Bluetooth about:

The slides of the session Marge, an open source framework for building Bluetooth applications in Java are available only in pt_BR (pdf and odf). mOOo Impress Controller was used to control the Impress presentation with the mobile and Giant Blue Pong was the demo showed in the end. Thanks for the audience, sorry if we had to hurry up. If you got any doubts, please send an email to us (mailing lists here).

During fisl, we have discovered a very nice thing! Bluecove, a JSR 82 Java SE implementation, is already working over BlueZ, the official Linux Bluetooth protocol stack. There is no release yet, but the snapshots we have tried are stable. Thanks to Vlad Skarzhevskyy, one of the project owners, that virtually helped us to put things working for our demo. Now you can have multiple connections in Linux, something that AvetanaBluetooth (open source) did not allow. Great news! Congrats to the Bluecove team! :)


Thanks,

Bruno Ghisi



Starting with Sun SPOT using NetBeans 6.1

Posted by brunogh on April 11, 2008 at 09:41 PM | Permalink | Comments (6)

If you do not have a Sun SPOT (Figure 1), do not be bored, you can still have a lot of fun! In this entry, I gonna explain how to start programming the world using NetBeans 6.1!



sun_spot2.jpg

Figure 1: Sun SPOT rulez!!!


Downloading NetBeans IDE 6.1


1. Download NetBeans IDE 6.1 (RC1 launched today). A lot of new nice features, take a look in the New and Noteworthy and in the release page for a detailed list.


Installing Sun SPOT plugin


2. Install Sun SPOT plugin into NetBeans. Download com-sun-sunspot-updatecenter.nbm. Now, in NetBeans, go to:
2.1 Tools menu -> Plugin.
2.2 Click on Downloaded tab.
2.3 Click on Add Plugins button and select the file. Then, confirm the installation clicking on Install button and accept the license agreement.
2.4 Finally, go to the Available Plugins tab, mark SunSPOTApplicationTemplate, SunSPOTHostApplicationTemplate and Sun SPOT Info, click on Install button and accept the license agreement.
2.5 You can check that everything is installed going to Installed tab (Figure 2).


PS: David Simmons has blogged about these steps before.


netbeans_spot1.png
Figure 2: Installed tab.


Getting Sun SPOT SDK 3.0 Beta


3. Get the Sun SPOT SDK 3.0 Beta emailing David Simmons, more details here. You will receive a link to download SPOTManager tool, that is a jar that installs the SDK and can run the emulator. Be sure you have at least JDK 1.5 and at least Ant 1.6.5 installed and configured in your system.


Creating the Demo Application


4. Let's make the default demo application work. Go to:
4.1 File menu -> New Project
4.2 Select Java category, select Sun SPOT project and then click Next.
4.3 Leave the default project name and package and click Finish.
4.4 Open org.sunspotworld.StartApplication.java. You can see it extends MIDlet and already has some code. If you are familiar with Java ME, you will not have big problems. But, basically, Sun SPOT arquitecture is CLDC (Connected Limited Device Profile) 1.1 and has IMP (Information Module Profile) in the top - which can be defined as a MIDP (Mobile Information Device Profile) without UI stuff. Also, it has some additional libraries and all this runs in a VM called Squawk, that is characterized by being most written in Java. So, StartApplication implements the abstract methods inherited from the MIDlet (startApp,pauseApp that Squawk never calls and destroyApp). It works in a sand box enviromnent.


The startApp code, in List 1, basically gets an object reference to the singleton eDemo Board and then make its LED blink red for a quarter of second each second. As you, can see, the code is pretty high level and easy to understand.



protected void startApp() throws MIDletStateChangeException {
System.out.println("Hello, world");
new BootloaderListener().start(); // monitor the USB (if connected) and recognize commands from host

long ourAddr = Spot.getInstance().getRadioPolicyManager().getIEEEAddress();
System.out.println("Our radio address = " + IEEEAddress.toDottedHex(ourAddr));

ISwitch sw1 = EDemoBoard.getInstance().getSwitches()[EDemoBoard.SW1];
leds[0].setRGB(100,0,0); // set color to moderate red
while (sw1.isOpen()) { // done when switch is pressed
leds[0].setOn(); // Blink LED
Utils.sleep(250); // wait 1/4 seconds
leds[0].setOff();
Utils.sleep(1000); // wait 1 second
}
notifyDestroyed(); // cause the MIDlet to exit
}


List 1: startApp code.


Running the Demo Application in the emulator


5. Put this application to run in the emulator.
5.1 Right click the project and select Build. It will generate the jar in the /$PROJECT_HOME/suite/. If you have a spot device, you could send it directly by right clicking the project and selecting Build Project + Deploy to Sun SPOT , forgetting the next steps.
5.2 Open the emulator (in the ToolManager, go to Solarium tab and then click in the Solarium button). Then, in the emulator, click on the Emulator menu -> New virtual SPOT, you will notice that a Sun SPOT will appear in the squared right area.
5.3 Right click on the Sun SPOT picture, then click Specify application jar file... and select the application jar in /$PROJECT_HOME/suite/, which is the place that the application was built in step 5.1.
5.4 After that, click again on it, then Run MIDlet and StartApplication. Finally, you will see a red LED blinking!!! Wow!



netbeans_spot2.png

Figure 3: NetBeans 6.1, ToolManager, Emulator and the red LED blinking!


Where I go next?


In NetBeans, check the Sun SPOT Info, that you have installed with the plugin, by clicking in the Window menu.
David Simmons' Blog - http://blogs.sun.com/davidgs
Roger Meike's Blog - http://blogs.sun.com/roger
Sun SPOT Feeds (really nice aggregator with more cool blogs) - http://planets.sun.com/SunSPOT/group/SunSPOT
Project Sun SPOT - https://www.sunspotworld.com
Open source Sun SPOT - https://spots.dev.java.net (take a look in its subprojects as well).
Search for spaughts in youtube.com or subscribe the tag feed directly.
Recently, Aaron Houston has organized a conference call about Sun SPOT with Roger Meike and published the nice links we get during it in an email he sent. The links are available here too. Slides here.




PS: I am using this entry for the NetBeans IDE 6.1 Beta Blogging Contest, take a look at http://www.netbeans.org/competition/blog-contest.html for more information about it. Go ahead, make an entry and have a chance to win $500! Good luck for us!




61blog-contest-logo.gif




Thanks! Have a nice weekend!


Program the world!


Bruno Ghisi



Building a Java ME Bluetooth chat in 12 minutes...

Posted by brunogh on April 02, 2008 at 08:05 PM | Permalink | Comments (0)

As it was announced before, Marge 0.5 is out. In this post, I am going to demonstrate an interesting new feature called AutoConnect. AutoConnect is indeed to automatically connect Bluetooth devices. It has some limitations due to some bad implementations and has some scenarios that maybe it is not the best option, but still very interesting and is definitely awesome to make something with a few lines of code! For more information about the new release and this feature, please check http://wiki.java.net/bin/view/Mobileandembedded/HowTo05.

So, nothing better than show a video... [sometimes I think I should have done cinema :) ]... Anyway, if you have not seen any Marge videos yet, try "Project Marge Interview", "My laptop is detecting my presence" and "Giant Blue Pong (my Bluetooth Atari)". Too much talk, take a look at the new "Building a Java ME Bluetooth chat in 12 minutes..." too. Could you not understand what happened in Netbeans code editor? Neither do I!!! It is better to download the full video (30MB). Hope you enjoy!

marduke.png

If you want more about Marge, go to http://marge.dev.java.net. If you want to help, please send an email to owner@marge.dev.java.net. We would love to hear suggestions and have you in our team!

Go ahead! Marge your Bluetooth app!



June 2008
Sun Mon Tue Wed Thu Fri Sat
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30          


Search this blog:
  

Categories
Community: Java Communications
Community: Java Tools
Community: Java User Groups
Community: JavaDesktop
Community: Mobile & Embedded
Community: NetBeans
J2SE
JavaOne
Mobility
Open Source
Tools
Archives

June 2008
May 2008
April 2008
March 2008
January 2008
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007

Recent Entries

Why do we write open source code?

Playing with Mobile Sensor API, Marge and JavaFX Script

First steps with iPhone and Java...



Powered by
Movable Type 3.01D


 Feed java.net RSS Feeds