Friday Jun 05, 2009

Mean Java Puzzlers, Swiss JavaFX usecases, and 3-D jME Games

While waiting for the NetBeans Platform development session to begin, let me quickly show you three other cool JavaOne 2009 sessions, and what I learned from them:

Java Puzzlers: Shlock and Awe

If you're not sure what that method does, it doesn't do what you think it does. Let the Java puzzler experts Bloch and Gafter introduce you to the pitfalls of the Java language - shlocking and awe-inspiring!

Java Technology for Gaming

The freely available Java3D game framework jMonkeyEngine solves many challenges that you will encounter when developing a Java 3D game. Learn how well-implemented collision detection and game physics add realism and immersion to your next killer game!

Technical Session: JavaFX Technology in Action: From Design Tool to Desktop, to Mobile Device

Canoo's Mike Mannion describes how his company used JavaFx to develop their Music Pinboard and then quickly migrated it from the browser to the desktop to mobile devices.

Wednesday Jun 03, 2009

Some Unsorted JavaOne Impressions

Did you see this year's nice JavaOne banners? Love the gradients and colors.

They look vaguely familiar though, don't you think?

Hm... ;-)

Cool things announced today: Blackberry, Sony, eBay, Oracle, they all love Sun, Java, or JavaFX (ranging from "respectively" to "all of the above")! There was a spiffy Sony Blueray presentation, the only thing I remember off the top of my head was this one "unique selling point" that made me laugh: "IM your friends while watching a movie!!!1!1!" Oh yeah? With you can even IM your friends as well as tweet, all while coding! Hah! Beat this, Blueray.

Seems I remember more of that demo than of Monday's general session. Someone please refresh my memory. You know, the segment where they had this mesmerizing "city lights by night" video loop in the background? Did I mention the video loop was exactly 8 seconds long? And that it was mesmerizing? o_O

(Heh. I just realized one of my colleagues here can make precisely this smilie face: o_O Very funny! Still trying to capture that on film.)

The big thing today of course was James Gosling's announcement of the Developers like you and I will be able to upload our Java apps, attach a price tag, and customers will be able to drag the app to their desktops to buy and install--pretty cool! You can join the beta program and vote on what buying method you prefer before the chosen one will be activated later this year. Presently there are free games like Solitaire and Runescape. But the private Beta is only available to US citizens, oh well...

Any beta store applicant here care to post a comment how you like it? (And most importantly: Did you get sucked into Runescape??) I talked to a guy after a session who said there were tags or something to specify whether your app was based on the jMonkeyEngine (and others)? Can anyone tell me whether these categories will be used used for licensing or packaging purposes?

Nandini actually mentioned the Java Store in her demo of the new visual JavaFX tools, just a few minutes before they officially announced it... I wonder whether she did that on purpose? :-P That would explain why the wireless was suddenly unusable in the hall, everyone tried to connect to tweet, blackberry, IM, skype, etc... Speaking of which, the wireless is called JavaOne (camel case), don't fall for the evil imposter JAVAONE (all caps).

Oh, and the JavaFX TV demo (JavaFX-written on-screen TV controls) memorably used the Big Buck Bunny open-source video: It's a cute short film, but the presenter was alert enough to call up a sports screen before it got to the scene where the squirrel KILLS THE BUTTERFLY!! I don't like this video. =-[ Nor can I warm up to the other open-source video, Elephant's Dream. Yes, I agree, it's extremely well done and creative, but the characters creep me out.

Oh, and I also went to the Maker Faire near San Mateo right before JavaOne, got some footage of steampunks and stuff, but no Mac/iMovie at hand right now.

Monday Apr 27, 2009

Mind Your Language, Silly!

Easter holidays are over, back to my old crazy Java 3D and 2D experiments and the fun idea I had for the JavaFX coding challenge! :-D ... Which... I of course cannot submit, since I'm an employee... :-| Oh well. All I can say is that the idea hinges on a highly advanced bleeding-edge stickfigure generator. I'll post it here if my app ever amounts to anything without the pressure of a deadline. :-P

What I like about JavaFX is how fast I learned the syntax and how much I get from a few lines of code. I looked at the sample projects included in the IDE and browsed the language overview (all tutorials) and basically whipped up my first app. I jotted down some revelations I had on the way, hope they are useful to you:

Java SyntaxJavaFX Syntax
The Java constructor needs explicit arguments, in order...
public class Pizza {
  public Pizza( int radius ){ ... }
... while the JavaFX constructor implicitly accepts all public variables, in any order.
public class Pizza {
  public var radius;
  public function create(){ ... } 
You made this variable public because you want it to be set, no need to repeat yourself -- nice.
Creating a new Java object...
Pizza p = new Pizza(16);
... versus creating a new JavaFX object.
var p = Pizza { radius:16 };
The order of arguments doesn't matter thanks to the labels. The argument type (here, integer) is inferred from the context (here, 16).
String concatenation operator in Java...
println("The pizza is "+radius\*2+"cm across.");
... versus evaluation braces in JavaFX strings:
println("The pizza is {radius\*2}cm across.");
You can import and use the classical packages such as\*...
BufferedReader in = new BufferedReader(
  new FileReader("bla.txt")
... but note the syntax change:
var in:BufferedReader = new BufferedReader(
  new FileReader("bla.txt")
Creating an JFrame application window in Java...
JFrame frame = new JFrame("Hello World");
JLabel text = new JLabel("Hello?");
frame.setPreferredSize(new Dimension(200,200));
frame.getContentPane().add(text, BorderLayout.CENTER);
... versus a JavaFX application window:
Stage {
  title: "Hello World"
  width: 200 height: 200
  scene: Scene {
    content: [ Text { content:"Hello?" } ]
That's it!

As you see above you still use standard Java packages for certain things (such as reading and writing files) that JavaFX has no need to reinvent since it focuses on GUI code. The NetBeans GUI Builder however does not support JavaFX yet, which is a pity. In the meantime you align GUI elements using javafx.scene.layout.VBox and and HBox and preview the results in the IDE.

When your app grows you will want to move individual javafx.scene.Nodes into classes of their own. Here's a very common pattern how to create a custom Node: The details are now defined inside the custom class and don't clutter the Stage. The return value can also be a javafx.scene.Group of Nodes.

File: Main.fx

import javafx.scene.\*;
import javafx.stage.Stage;

Stage {
    title: "Pizza Window"
    width: 200 height: 200
    scene: Scene {
      content: [
        Pizza { radius:16 } // create a new object

File: Pizza.fx

import javafx.scene.\*;
import javafx.scene.effect.\*;
import javafx.scene.shape.\*;

public class Pizza extends CustomNode {
  public var radius:Integer;
  override public function create():Node{
      Circle {
        centerX:100 centerY:100 radius:radius 
        effect: Lighting{}

You can quickly compile these two files on the command line using javafxc Main.fx and then run them using javafx Main -- Or create a NetBeans project.

Another cool thing in JavaFX is binding: You bind an input element (a slider or field) to a variable, and bind the variable to an argument. For instance, the slider is bound to the variable that is bound to the image size. When the user moves the slider, the image is scaled immediately, no explicit event handling necessary! Also have a look at sequences and for-loops, these expressions are fun to use. Whoever invented these features was obviously annoyed about the same things as I. ;-)


During my first tries to compile stuff I kept getting this annoying error and didn't know what it meant:

Pizza.fx:40: cannot find symbol
symbol  : constructor Pizza(int,boolean)
location: class Pizza
             def p = new Pizza( 16 );
Note: The following error is an internal error in the OpenJFX compiler (1.1.1).

Wait a second -- My constructor doesn't even use any Boolean arguments, where does this come from? Seems that out of a habit, I created the JavaFX object using Java's "new" syntax... After I changed the offending line to def p = Pizza { radius:16 }; the compiler is happy. It would be nice if the JavaFX compiler could identify this case and just say "You're talking Java again, silly!" -_-

Wednesday Mar 18, 2009

How's Your Chinese?

Remember Geertjan & co's NetBeans platform book? It has recently been translated to Chinese and Geertjan just got his copy. :-) Seen through the eye of my year-old mobile camera, it looks like this:

(I'm still surprised every time how this mobile cam manages to distort the perspective, "enhance" the colors, and give every photo an "artistic water color" effect! You couldn't do that on purpose if you wanted to...) ;-)

So, if you like a book about the NetBeans, or read Chinese, or optimally both, get your copy here.

Thursday Feb 05, 2009

NetBeans in Wonderland (Part 2)

In part one, I talked about what project Wonderland is and where you can try out a live demo of version 0.4. Much like SecondLife, Wonderland is a 3D world with avatars and audio/text chat. But unlike SecondLife, Wonderland is open-source and more business-oriented, for instance there's live application sharing. You can use it to collaborate on projects with your team of developers in a private 3D world.

Part two is about how to set up your own Wonderland server and client. I will share an instance of NetBeans in this example, but of course you can share any Xwindows application, including the Terminal.

Prerequisites: Solaris/Linux

Windows and Mac versions of the Wonderland 0.4 server don't seem to be available yet, so presently Solaris or Linux are a prerequisite. Note that Wonderland clients (including a webstartable one) are available for all operating systems. In this example I use OpenSolaris, and the instructions should be identical for Linux.

Prerequisites: Java

Before running Wonderland, make sure you have JDK 6 installed. (Use the terminal commands javac -version to check). If you don't have javac, install the JDK 6. On Solaris, go to the main menu, choose System > Administration > Package Manager, and install the java-dev package from the Development category.

Prerequisites: Installing the Shared Application

Obviously the application that you want to share must be correctly installed and on your PATH. In this example I downloaded and installed NetBeans. Check whether NetBeans is in your PATH by typing which netbeans at a fresh Terminal prompt. If the command returns empty, you need to add NetBeans to your PATH before proceeding. Find out where the NetBeans binaries were installed -- in my system, it's in the /opt/netbeans-6.5/bin/ directory. Remember this path and add it to your config file (I use the bash shell, so for me the file is .bashrc).

ruth@sonnig:~$ gedit ~/.bashrc

Add your netbeans binary path in the following way and save the file.

export PATH=$PATH:/opt/netbeans-6.5/bin/

Reload the .bashrc configuration (in every open Terminal window).

ruth@sonnig:~$ source .bashrc

Test whether NetBeans was successfully included in your PATH.

ruth@sonnig:~$ which netbeans

Installing Wonderland

Now it's time to install Wonderland. Go to and download the binary build (for example, and extract the archive.

ruth@sonnig:~$ unzip

Change into the wonderland directory and edit the settings.

ruth@sonnig:~$ cd lg3d-wonderland/bin/
ruth@sonnig:~$ gedit  ../

Modify the following lines to include your host name and IP address, and save the file. (You will have to redo that if you use DHCP and are assigned a new IP address.)


Starting the Wonderland Server

OK, you're all set! Now it's time to start the server. According to the instructions, you run the binaries as follows:

ruth@sonnig:~$ ./
ruth@sonnig:~$ ./
ruth@sonnig:~$ ./

Starting the Wonderland Client

Finally, start a Wonderland client and connect to your server. The client can run on any operating system, on the same host or on a different one, webstart or desktop app, it's up to you. The only requirement is that the host must support 3D graphics. (Since my OpenSolaris runs in a virtual machine and VirtualBox cannot handle 3D graphics, I use the Mac client.) When the login dialog appears, enter the IP address that you specified above, pick any username, and connect.

Welcome to your very own Wonderland. :-) You walk around using the arrow keys. Select Netbeans from the Shared Apps submenu and find the window floating in the room. Gain/release control of an application by Shift-Left_clicking the window title. Tip: I don't know what Solaris thinks ctrl-space is, but it didn't trigger code-completion; so I'm using ctrl-\\ instead.

A shared application (here NetBeans) in 3rd-person view and in Best View (Shift-Right_click)

Now it's time to invite some friends over: Ask them to webstart the client, give them the Wonderland server's IP address, and have a little chat around the campfi-- um, around the IDE. Hmm. Around the IDE...? Well, it is a 3D world... What if I walk around the IDE and look at it from behind?

Behold. The far side of NetBeans! :D

The next step is to load custom 3D models (more documentation is here). But I'll wait until I migrated my stuff to a Linux machine -- VirtualBox is nice, but seeing that it takes up way over 50% of my RAM gives me fits of claustropobia. ;)

Wednesday Feb 04, 2009

NetBeans in Wonderland (Part 1)

Getting to Know Wonderland - Cybertech news reviewed Sun's Wonderland: A free open-source toolkit for building virtual 3D worlds in pure Java. Access a public Wonderland server or set up your own as a meeting point for your distributed team. Wonderland is based on Project Darkstar, a multi-user 3D world server.

Accessing the Wonderland Demo - To see for yourself, go to the education grid and click Enter the Grid, then click Sun Microsystems.
The browser opens a Java Web Start (JNLP) file. When the Java plugin asks about signatures, click Run (or Trust respectively) to continue. Your browser then downloads the Wonderland application to your desktop. (In my case the app detected an outdated Java3D installation, and gave me instructions how to remove them. I then double clicked the Wonderland app to continue.)
At the login dialog, type in any name (the demo does not require any registration), and create an avatar. The avatar is way less detailed than the ones in SecondLife, basically just hair and cloths colors.

Navigating in Wonderland - Note the View menu (1st/3rd/orbit view) and Placemarks (quick navigation). Walk and turn with the arrow keys, sidestep with Z/X, fly by pressing Q. Also try pressing numbers to trigger gestures like nodding and waving. Keep the right mouse button pressed to look up, down, left and right. The middle mouse button controls the right arm, and you use it to point at things. Walk around a bit and don't miss reading the crazy posters in the conference room!

Listening to Wonderland - The main means of communication in Wonderland is audio chat, but there is also a text chat interface. Invite a friend to webstart the client and log on simultaneously, and have a chat with him. A cool feature that you will immediately notice is 3D audio: Approach talking avatars, and their volume increases, and sounds from further away fade out. In case nobody is "home", the demo includes a couple of bots who talk about nothing but Darkstars and Blackboxes all day. :-)
The freely available Wonderland server supports interactive objects such as microphone stands (for room-wide announcements), telephones (think Skype), a cone of silence (for private conversations), and answering machines (to record and play audio). People who call into the world by phone are represented by floating spheres. Since a caller cannot navigate the 3D world (they wouldn't see where they are going), avatars in-world can help out by carrying the caller's sphere to another room, or by placing them in the Cone of Silence or in front of microphones. Pretty neat stuff. :-)

Sharing Applications - Wonderland allows you to share Xwindows applications from your desktop with other avatars. Log on to the public demo, walk around in the Demo Room, and try out the red-framed windows -- e.g. there's a whiteboard for drawing and a photo browser. Shift-left_click the frame to gain control over the application, then shift-right_click to move the camera to an optimal position. All keyboard input will now be sent to the shared application. Shift-left_click the frame again to release the application, and press escape or C to reset the camera position. Live application sharing, now that's something that Second Life doesn't have, eh? :)

Sharing NetBeans? - Why am I posting this in the NetBeans category? Can I stick my instance of the IDE to a wall in the 3D world, and my colleagues' avatars can use it as if they were standing right next to me?
Yes! Note however, although there is a NetBeans menu item in this demo, it is not active. Bummer. Those heartless people run the Wonderland server on a machine with no NetBeans installed! :-/ But setting up a local instance of the Wonderland server is easy, and if I run the server on Solaris or Linux, I can share apps such as NetBeans myself... Hm...

What will NetBeans be like in 3D? Will I be able to do code completion and window undocking? And will I be able to see NetBeans from behind? :-o Read part two of this blog entry to find out!

Wednesday Jan 28, 2009

Let's All Switch to ASCII Video

Quick free-form poll: For learning, do you prefer...

  • ... visual screencasts or textual tutorials?
  • ... screencasts with audio? With call-outs? With captions?
  • ... short and simple clips? Extensive video trainings?
  • ... screencasts with transcripts? Tutorials with embedded clips?
  • ... more linkage between related tutorials / screencasts / sample code?

I prefer text over video, unless it's a clearly visual topic (say, GUI builder) where only a screencast makes sense. I also know that non-native speakers of English prefer screencasts because they see what happens and don't have to follow the words.

I usually have more patience watching a short clip than an hour-long video, often they proceed at a faster or slower pace than I, which can become annoying. Similarly, I prefer videos with call-outs/captions/transcripts over audio-only, because it lets me read at my own pace. Not being dependend on the audio track also helps with speakers' accents, or in a busy environment (office).

Obviously, adding a transcript of the audio track increases production time (less time for other tutorials to be written), and recording audio takes longer than writing simple call-outs. So be careful what you wish for: Do you rather want content in an optimally accessible format, at the cost of it covering fewer topics? Or you don't care about the format, it can be txt or screenshots, just as long as it covers the whole spectrum of the technology you're learning about?

PS: Do you know the ASCII art library (AAlib)? It converts video to ASCII text. Just in an... unexpected way... :-D

Thursday Jan 22, 2009

100 NetBeans Tips and Tricks (ebook)

Since the ebook announcement rolled off the front page now (watch out for the contest coming soon), and since people have been asking, here another quick plug ;-) for our latest ebook, 100 NetBeans Tips and Tricks. Yup, it's the same book that was given away to attendees of the NetBeans Day at JavaOne last year; that makes the print version so rare, you can't even get it on Ebay. ;-P

Wednesday Jan 14, 2009

Thanks For Voting For Your Favorite IDE!

It is worth noting that in the past Sun has been able to dominate many categories, but it took multiple products to achieve that distinction. This year one product, NetBeans, dominated the categories by winning five out of twelve. -- Product of the Year 2009

Yay! :-D

The five winning categories were:

  • Development Tool: NetBeans Platform,
  • Development Utilities: NetBeans Profiler,
  • Wireless/Mobile: NetBeans IDE 5.5 Mobility Pack for CDC,
  • Java Tool: NetBeans IDE,
  • Open Source: NetBeans

Thanks for your votes! :)

Red is Beautiful in Russian

Thanks for your continuing efforts to translate pages into your native language! If you have checked the localization status page recently, don't be shocked if the column for your language is suddenly all "red". This is because we switched the table to the new 6.5 docs set. If you want to help us by updating a document, get in touch!

Monday Jan 05, 2009

The Cube! It's alive! (continued)

Happy new year everybody! Previously I mentioned that the NetBeans mascot, NekoBean has already been incarnated as plush toy, pendant, etc. Thiara went yet another step further: She posted instructions how to cut and paste (literally) a 3-dimensional NekoBean — as office decoration. :-D

If you don't read German, here's the translation:

  1. Print the NekoBean template (PDF) on scrap paper, cut out the shape, and draw the outline on the backside of construction paper — unless your printer can handle fancier kinds of paper directly. The shape consists of the body, 4 legs, tail and 2 ears.
  2. Cut slots into the body: Two on the sides for the arms, two on top of the head for the ears, and one into the backside for the tail. Insert the arms, ears, and tail, and glue or tape them on the inside of the body.
  3. Draw the NekoBean's face on the frontside with a felttip pen. Here you find some faces for inspiration.
  4. Glue the sides of the body together to form a cube -- when closing the cube, don't forget the legs: Make them stick out of the edge between the backside and the bottom.

End result: Meet my first makeshift Nekobean! (It was born solely of office materials... I colored the paper with a flipchart marker and glued it together with sticky tape...)

It hangs on nicely to a notebook screen, and it is equally well able to stand on flat surfaces. Thanks to Thiara for this hilarious tip!

PS: Now create your own and post photos!

Tuesday Dec 09, 2008

The Cube! It's alive!

Two things that came as a complete surprise to me this weekend:

Malta versus Prague
  1. The island (and country) of Malta is smaller than Prague.

  2. The NetBeans Cube is alive! OK, we already knew the Japanese community created NekoBean. And yes maybe a video, a wallpaper, and a logo or two. But... the plush toys and pendants were news to me! Way to go, Japanese community!

    1. PS: Et tu, James Gosling!

Thursday Dec 04, 2008

JavaFX 1.0 is out now!

We just spent haaalf of our afternoon refreshing and in our browers -- and lo, here it is, JavaFX 1.0. :)

If you've already got NetBeans 6.5, go to the update center (Tools > Plugins > Available Plugins) to install the plugin(s). If you don't have 6.5 yet, you can download the IDE including JavaFX support here.

I say plugins above because there's also a special Mac SDK, a debugger, and a sample project on the update center. At minimum you need JDK 6_10, the JavaFX 1.0 plugin (and the SDK if you are on Mac OS).

You can use JavaFX for webstarting apps (JNLP), desktop apps, mobile apps, and Applets ("They are baa-aack!"), just like Java. You can keep your existing Java code and use JavaFX to spice up the user interface if you like. Look at these tutorials and sample applications online. Download the sample code to get started -- That's at least what I'm doing right now. :)

Thursday Nov 20, 2008

NetBeans IDE 6.5 Screencasts

NetBeans IDE 6.5 is out, and to celebrate the occasion I updated the NetBeans 6.x screencasts page.

Highlights: In October and November, Geertjan recorded a great 3-part series of Groovy & Grails introductions, and also a very thorough 4-part NetBeans Platform API series. The Platform screencasts average out at 30 min per video, so you're basically getting a whole expert training for free, very cool!

Other new 6.5 tutorials show off the new PHP support (there will be more coming!), JavaScript, Rails and web applications running on the GlassFish v3 Prelude app server, and RESTful web services. Have fun, and leave comments!

Tuesday Sep 30, 2008

NetBeans Innovator Grant Winners Announced

You may have already seen it on, the winners of the NetBeans Innovators Grant have been announced. 13 open source innovators completed their projects and won prizes between $2000 and $11000! In the latest NetBeans podcast, Jiri Kovalsky mentions how impressed he was by the overall professionalism of the submissions. Although it always happens that project owners have to step back for various reasons (the program started out with 20 candidates), it was obvious that the teams took their projects very seriously.

Here are the projects that I liked best, you can get the full project list on the grants page.

  • MONOH (named after the exclamation "[look] MOmmy, NO Hands!") lets you control Netbeans with spoken commands! :-D From experience I know that speech recognition thingies never really work for me (and I can't use it in an office environment anyway), but it's definitely the coolest idea.
  • The Darkstar plugin adds support for massively multi-player online game development with the Darkstar server in NetBeans, and also some kind of Java ME support, but I didn't understand what exactly (anybody know?).
  • The Sun SPOT plugin adds Sun SPOT project support to NetBeans (SPOTs are small Java-programmable devices with sensors).
  • Cube°n was inspired by Eclipse's Mylin plugin and integrates task and bug tracking into the NetBeans IDE. (Screenshot)
  • IvyBeans brings Apache Ivy project dependency management to your NetBeans projects. (Demo)

The news item contains more background info and two more quotes by winners.

I'm gonna try MONOH at home, and tell you more about it later this week. I'd have a nice idea what to do with two Sun SPOTs (think: Wii remote control), but before I shell out 600 Euros I need to think it through. Setting up my own Darkstar game server sounds tempting too. ;-) Well, if you have tried any of these new plugins and applications, please share your opinion with us! And if you want to join one of the projects and contribute to it, write the project owner.


NetBeans IDE, Java SE and ME, 3D Games, Linux, Mac, Cocoa, Prague, Linguistics.


« June 2016

No bookmarks in folder