Oracle acquires Sun: Who needs to look out now?

As a Java developer who does a lot of work with Oracle products including Jdeveloper and ADF, my head is still spinning a little from the news that Oracle is buying Sun Microsystems.

Oracle buying BEA hurt a little, though it was completely expected and a great move on Oracle’s part, I was a little sad to see the application server competition field drop by one but I was very happy that Oracle was smart enough to choose Weblogic.  At that point it was really the only the decision they could make.

With Oracle buying Sun there is a lot of synergy, there are many technologies that are duplicated among both companies.  Oracle owning both should make those technologies better and enable them to compete with the leaders in those respective areas.  The big ones that stick out for me:

!. Oracle’s JDeveloper and Sun’s NetBeans

Could they really afford to drop NetBeans, probably not, but can they afford to drop JDeveloper, no, not really.  Here the only thing that really makes sense is to merge the two, probably adding in the ADF wizards and goodies like that into NetBeans.  At least, that is what I hope they do.  JDeveloper isn’t bad, but I only ever use it to develop ADF projects and I bet many, many people are in that same boat.  Combining the two could end up giving Eclipse a run for it’s money, hopefully the competition just spurs both to be better.

2. Oracle’s Oracle VM and Sun’s Virtual Box

I haven’t had much experience with Oracle VM, but I have lately become a huge fan of Sun’s Virtual Box.  It’s a great product and it lets me do everything I want for free.  Will this continue to be the case?  I don’t know.  I’m not an expert on virtualization in the enterprise, I use it for desktop VMs, but I hadn’t seen much about Virtual Box working in that space.  I would imagine Oracle VM is all about virtualizing the network and competing with VMWare on that level.  With the two together VMWare’s got some competition.

3.  Oracle’s Unbreakable Linux and Sun Solaris

Oracle had a great jumpstart to their linux platform basing it on the RedHat codebase way back when.  Solaris was my first exposure to any type of Unix (Solaris and AIX, actually) and it has been around forever.  If the adoption of Linux has hurt anything, it’s probably been Solaris and through that, sales of Sun’s hardware.  Oracle says that their owning of Solaris will enable them to tune the Oracle Database software to run even better on it, and since according to Oracle, most of their database customers are using Solaris, I think they’ll probably do that.  I have no idea what will have to Unbreakable Linux though.  Who has to look out with this one?  I’d say IBM.  Buying Sun probably would have been good for them in the products space, I think the only area IBM is going to be competing in future is going to be services.  RedHat has Ubuntu to worry about on the desktop side and now a bigger threat from Oracle and Sun on the server-side, they have their work cut out for them.

4.  Oracle Database and Sun’s MySQL

MySQL has a huge customer base, most of them probably non-paying.  I think with this one, Oracle just adds it to their ever increasing repetoire of niche databases.  It won’t go away, but I see less adoption in the future, maybe a boost for PostgreSQL if they can get their act together.

5. Sun’s Java and Oracle’s ADF

Oracle has always been a big player in the specifications for the Java language.  I’m sure someone else will go into all the details, because I honestly don’t know them off the top of my head, but I do know that many technologies and ideas that ADF is based on where either approved JSR’s or close to approved JSR’s.  Does Oracle’s acquisition of Sun and Java mean that they will be better equipted to push trhough whatever they want to add to the language?  Well, I don’t think it will be quite that easy, but I’m sure it makes it easier.

I’ve always been a Java guy at heart, I work with Oracle technology sometimes, and I think they have really come a long way, but Oracle owning Java does kind of scare me a little.  One thing Oracle does really well, and JDeveloper is great at this, is making complex technologies easy to use.  It is what Microsoft does really well.  .NET makes easy the things that Java makes hard.  ADF actually does a lot of the same.  The combination of ADF and Java together could pose a big threat to Microsoft’s .NET if Oracle does it right.

My first thought about Oracle owning Java is that many developers are going to jump up and down about it and complain.  Some will probably jump ship, maybe to .NET but probably to Ruby or PHP or something else.  I don’t think many coroporations are going to change the direction of their IT departments though, so for them, it will be .NET or Java as it always has.  In the end, I thnk most Java developers are going to remain Java developers and hopefully Oracle’s backing of Java will just end up making it a better language to work with.

Microsoft might have more to worry about with Oracle owning Open Office now also.  I hope that Oracle continues to invest in it, or it’ll end up being Microsoft Office vs. Google Apps and that’s about it.  I’m all for cutting edge, but Gmail hasn’t come out of Beta yet and I’d like to see Microsoft have some competiion in this area.

So I wanted to get my thoughts out there while they were floating around in my head and hopefully yours so I could hear your opinions on the topic.  Please let me know what you think about this acquistion and what you think it means to the future of technology and competition in the field.

Share/Save/Bookmark

JavaFX Flashcard Example Updated for 1.1

I have updated the sourcecode for my JavaFX flashcard game example to be compatible with release 1.1.  There certainly were a lot of changes from the pre-release to the release and this serverely impacted the example code.  So severely, in fact, that it was just chock full of compile erros and other issues.  I will attempt to cover most of the changes by explaining the resulting new classes.

The actual structure of the program hasn’t changed, The FlashcardApp is the main program, it builds an array of Flashcard objects.  Each Flashcard object is made up of a Word and a CardImage.  The Word is then made up of individual letters.

Let’s start by taking a look at the Letter.fx file.  This Letter.fx is a little better designed than the last one.  In this case, instead of extending the generic CustomNode I extended Text.  After doing that I was able to just override the variables I was interested in. I could set the alignment, font, color and relative position this way. Another change that had to be made was to drop using attribute and use var instead.

I stored the actual letter as a String because I wanted the option of tying two characters together to make one sound (called bends (”cl” or “st”) or diagraphs (”sh” or “ch”)).

The letter is class is repsonsible for displaying the letters and thus needs to know where to position them, therefore the size and position numbers are provided so it can determine where in the canvas to put the letters.

public class Letter extends Text {
    public var myLetter: String; //String the represents a Letter in the Card
    public var position: Number; //Position the letter is in in the current word
    public var size: Number; //Size of the entire word
    override var textAlignment = TextAlignment.CENTER;
    override var textOrigin = TextOrigin.TOP;
    override var translateX = bind ((scene.width - 40) - (((scene.width-40)/size) * (size+1 - position)));
    override var translateY = bind (scene.height - scene.height) / 2 ;
    override var font = Font{ name: 'Arial', size: 150 };
    override var fill = Color.BLACK;
    override var content = bind myLetter;

}

The Word.fx file did not change too much except to extend CustomNode and override the translateX and translateY variables to position the word correctly.

It contains an operation to flip the card, one to show the Word (to reset the state), and a constructor. The interesting part here is the “constructor”. As I mentioned in a previous post, there is no real constructor per say, instead you define a method with the same name as the class and this is used as a constructor.

public class Word extends CustomNode {
    var letters: Letter[];
    var show:Boolean = true;
    override var translateX = bind (scene.width - 40 - boundsInLocal.width) / 2 ;
    override var translateY = bind (300 - boundsInLocal.height)/2 - 20 ;

    public var word: String = null on replace {
       var aSize = word.length();
       var i = 0;
       while (i < aSize) {
            var nLetter = Letter { myLetter:word.substring(i,i+1) position:i+1 size:aSize};
            insert nLetter into letters;
            i++;
       }
    }

    public function flip() {
        show = not show;
    }

    public function showWord() {
        show = true;
    }

    public override function create(): Node {
        return Group {
            visible: bind show
            content: [
                letters
            ]
        };
    }
}

The CardImage file is similar in the changes there. I also made use of fitWidth and fitHeight to make all my images consistent sizes in the ImageView.

The show boolean is used in the CardImage class and the Word class to indicate whether or not it should be visible. This is what allows the flip() function to work in FlashCardApp by just setting one to true and the other to false.

public class CardImage extends CustomNode {
    override var translateX = bind (scene.width - 40 - boundsInLocal.width) / 2 ;
    var show: Boolean = false;

    public var imageSrc: String = null on replace {
        show = false;
    }

    public function flip() {
        show = not show;
    }

    public function hideImage() {
        show = false;
    }

    public function CreateCardImage(anImage:String) : CardImage {
        var cardImage1 = CardImage { imageSrc: anImage
        }
        return cardImage1;
    }

    public override function create():Node {
        var cardImage = Image {
            url: imageSrc
        }
        return ImageView {
            translateY: 25
            fitWidth: 500
            fitHeight: 250
            visible: bind show
            image: cardImage
        }

    };

}

Nothing too exciting in the FlashCard.fx file either, but I’ll include here for the sake of completeness. Note the flip function here as mentioned above. Also, this is the class where the sound integration is done. It isn’t as much sound as I originally intended as it was originally meant to be able to sound out individual letters or letter groups. I don’t think that would be too difficult to implement but I haven’t done it yet and probably won’t since my children have outgrown this little game already.

public class FlashCard extends CustomNode {
    public var cardImage: CardImage;
    public var showFront: Boolean;
    public var cardWord: Word;
    public var mp3: Mp3;

    public var aWord:String = null on replace {
       cardWord = Word{ word:aWord };
    }

    public var anImage:String = null on replace {
        cardImage = CardImage{imageSrc:anImage};
    }

    public var aMp3:String = null on replace {
        mp3 = new Mp3(aMp3);
    }

    public function showWord() {
        cardWord.showWord();
        cardImage.hideImage();
    }

    public function flip() {
        cardWord.flip();
        cardImage.flip();
        mp3.play();
    }

    public override function create():Node {
        return Group{
            content: [
            Rectangle {
                x: 10
                y: 10
                height: 300
                width: 550
                arcHeight: 20
                arcWidth: 20
                fill: Color.WHITE
                stroke: Color.BLACK
                strokeWidth: 2
            }
            ,
                Group {
                    content: [ cardWord,
                            cardImage ]
                }
            ]
        };
    }

}

FlashCardApp.fx had a couple of changes and some things of interest. First of all, instead of using a Frame, it uses a Stage component, as the Frame no longer exists. Inside the VBox I had to put the content inside a Group in order for the displayed FlashCard to be updated when the index changed. Essentially I needed to bind the “card” variable and I could not do that without it being inside a Group component.

The last thing I had to change was to remove a slash from the pointers to the images and mp3’s. The old insert statement looked like this:
insert FlashCard{aWord:”cat”, anImage:”{__DIR__}/img/cat.png”, aMp3:”{__DIR__}/sounds/cat.mp3″} into flashcards;

Note the “/” after the {__DIR__} in both instances. I had to remove that slash so that it now looks like:
insert FlashCard{aWord:”cat”, anImage:”{__DIR__}img/cat.png”, aMp3:”{__DIR__}sounds/cat.mp3″} into flashcards;

At first I thought this might have been because i was developing this new version on Linux, but it appears that it is necessary for Windows also. It appears the {__DIR__} includes a slash at the end of the directory and having 2 was a problem for the classes.

var flashcards:FlashCard[];
var myIndex:Integer = 0;
var size:Number = 5;
var card = bind flashcards[myIndex];
insert FlashCard{aWord:"cat", anImage:"{__DIR__}img/cat.png", aMp3:"{__DIR__}sounds/cat.mp3"} into flashcards;
insert FlashCard{aWord:"dog", anImage:"{__DIR__}img/dog.png", aMp3:"{__DIR__}sounds/dog.mp3"} into flashcards;
insert FlashCard{aWord:"car", anImage:"{__DIR__}img/car.png", aMp3:"{__DIR__}sounds/car.mp3"} into flashcards;
insert FlashCard{aWord:"hat", anImage:"{__DIR__}img/hat.png", aMp3:"{__DIR__}sounds/hat.mp3"} into flashcards;
insert FlashCard{aWord:"fish", anImage:"{__DIR__}img/fish.png", aMp3:"{__DIR__}sounds/fish.mp3"} into flashcards;

Stage {
    title: "Flash Card JavaFX"
    width: 600
    height: 400
    scene: Scene {
    fill: Color.GREY
    content: VBox {
        content: [
            Group { content: bind card },
            HBox {
                content: [
                    SwingButton {
                        translateX:0
                        translateY:10
                        text: "Next"
                        action: function() {
                            flashcards[myIndex].showWord();
                            if (myIndex < (size - 1)) {
                                myIndex++;
                            } else {
                                myIndex = 0;
                            }
                        }
                    },
                    SwingButton {
                        translateX:20
                        translateY:10
                        text: "Flip Me!"
                        action: function() {
                            flashcards[myIndex].flip();
                        }
                    }
                ]
            }

        ],
        }
    }

You can download all of the new sourcecode here. You will need the JLayer library for the Mp3 class to compile.

Be sure to check out the other articles on my blog related to JavaFX and the Flashcard game for more details on the Flashcard JavaFX code itself.

Stephin Chin has a good post about some of the changes from the pre-release to the release.

Share/Save/Bookmark

Create and Deploy a JavaFX WebStart Application

I realized when I updated my FlashCard JFX game that I could not remember what I actually had to do in order to create a deployable Java WebStart application. So that I always had a simple reference to refer to, I’m posting it here. Hopefully this will help someone else.

Basically, a JavaFX application is typically deployed through Java Web Start, so I think most of these instructions will apply to any Java Web Start application. Steps 1 through9 are from the help in NetBeans itself. The part about signing the jars is from Kirill Grouchnikov’s blog.

1. Use NetBeans - there are other ways, but this is a requirement to follow my way.

2. Install the JavaFX plugin.

3. After running your project locally and making sure it works and all the dependencies are there, right click on the project and choose “Properties” from the menu.

4. Choose Categories: Application -> WebStart.

5. Check “Enable WebStart”.

6. Fill in the codebase to the directory where you will copy up the dist folder to on your web server. For me it is “/downloads/flashcardjfx/dist”

7. Choose “Run” from the Properties list.

8. Name the configuration and check “Run with Java Web Start”.

9. Clean and build your project.

10. Cd to the dist directory of your Java FX project.

11. Run keytool using something similar to this:

keytool -genkey -keystore javahair.keys -alias / -validity 365

12. Sign your main jar by running something similar to this:

jarsigner -keystore javahair.keys -storepass ***** FlashcardJFX.jar /

13. Cd to the lib directory in your dist and sign all the jars there like so:

jarsigner -keystore ..\javahair.keys -storepass ***** javafxrt.jar /

14. FTP all the contents of your dist directory to your webserver to the codebase directory you specified in step 6.

Now link to the launch.jnlp file in that directory and you should be good to go.

The older articles in this how-to can be found here:

Learning JavaFX

JavaFX Example - FlashCard Game

JavaFX FlashCard Source Code and Web Start Link

Adding Sound to the FlashCard JavaFX Game

Share/Save/Bookmark

Adding Sound to the FlashCard JavaFX Game

I finally had a small amount of time to look into adding sound to my flashcard java fx example, something I have wanted to do for a while now. When I finally got the time, I realized that it isn’t so difficult since most of the hard work has already been done.

The first step in adding any major functionality to an application like this is searching Google to see if anyone has done this before. I found an example of using MP3’s in a JavaFX application, but I didn’t like it. I didn’t like it because the article seems to point to using this embeddedmp3 library which I did not see the source for. The library in the article, however, is based on JLayer, and JLayer is what I used for my FlashCard game.

After including the 1.0 version of JLayer into my project, I created a utility class to be used for playing the np3 files. I called it Mp3.java.

What I wanted was a class that would hold a reference to the mp3 to be played for a particular card, so I decided that it would have a private attribute to hold that location. My first mistake was forgetting the type of application I was dealing with and I used a String pointing to the actual file to hold the location. I looked at what I was doing for images and just did the same sort of thing.

For the images I was storing them inside the jar itself in a package “flashcardjfx.img”, so for the mp3’s I put them in a package called “flashcardjfx.sounds”. The constructor for my Mp3 class (which at this point, is not really a util anymore, but once I put it in that package I was too lazy to move it) takes a String that is the location. I saw that the JLayer Player needs an InputStream so I created a FileInputStream on that location and was storing that.

When I tried to test my application, I kept getting an error that the file could not be found. I think when I moved the mp3’s to a c:\sounds directory, they were found, but that wasn’t going to help me much when I deployed. So, what to do? Well, after playing around with it for a little while, it dawned on me, that the String I was passing to the Image was not for a file, but a URL. Of course, right? I am dealing with JavaFX here and an application running via Web Start. So… once I changed my reference from a File to a URL, bingo!, it all started coming together.

My MP3 class is shown here, it is also now included in the down-loadable source code.

public class Mp3 {
    private URL url = null;

    public Mp3(String url) {
        try {
            this.url = new URL(url);

        } catch (IOException ex) {
            Logger.getLogger(Mp3.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    public void play() throws FileNotFoundException, JavaLayerException {
        try {
            //Make sure to open and close the player each time!
            Player mp3Player = new Player(url.openStream());
            mp3Player.play();
            mp3Player.close();
        } catch (IOException ex) {
            Logger.getLogger(Mp3.class.getName()).log(Level.SEVERE, null, ex);
        }
    };  

}

Simple, right? Not much to it. To use it in my FlashCard JavaFX class I had to add a private variable to hold the “Mp3″.

private attribute mp3: Mp3;

Then, at the end of the flip() operationI added this line:

mp3.play();

And that is about it to get it to play.

For the constructor, I added a String to the location of the mp3 and I just set my mp3 variable to a new Mp3 instance based on that location:

   operation FlashCard.FlashCard(aWord:String, anImage:String, aMp3:String) {
      mp3 = new Mp3(aMp3);
      word = new Word(aWord);
      cardImage = new CardImage(anImage);
   }

Now to create a new flashcard, I just pass in the mp3 location as well as the word and the image location.

insert new FlashCard("cat", "{__DIR__}/img/cat.png", "{__DIR__}/sounds/cat.mp3") into flashcards;

It has dawned on me that if I keep the naming structure the same, I only need to pass in the word, but that may be too much menial cleanup work for something that is just an example.

So the new source is available where the old source was: here.

The application itself can be launched by clicking here. You can thank my youngest daughter, Cassie and myself for the voicework. I will probably update with a version that does not use my voice, as either her’s or her sister’s is much better.

The older articles can be found here:

Learning JavaFX

JavaFX Example - FlashCard Game

JavaFX FlashCard Source Code and Web Start Link

I’ll be posting an article about deploying since I couldn’t remember how to do it this time either.

Share/Save/Bookmark

JavaFX FlashCard Source Code and Web Start Link

This is the post I promised that contains a link to the source code for the FlashCard game. There is also a Web Start Launcher link so you can see what my “masterpiece” looks like for yourself.

Some things that I need to work on:

1. Commenting - only parts are commented and though the variable names are pretty self explanatory, it could use some better commenting so that a write-up does not need to accompany it.

2. Layout - I used a couple Box layouts and I’m beginning to think that I should have just gone straight to the old GridBag. I haven’t spent much time figuring out how to space the components yet, but it isn’t spaced the way I’d like it to be.

3. Integrate with Pojo’s - I’d like to use some properties files and a few plain old Java classes to read in the properties and set up the array of flashcards. Currently the array is hardcoded into the FlashApp file.

4. Sound - I want to add sound to the letters, and sound to the images so that when they are clicked on, the letter sound plays or the word sound plays. I downloaded a package to let me integrate sound, but I haven’t gotten to it yet.

If you are interested in the current code, you can find it here.

If you want to see the game in action and you have Java 1.5+ installed, click here to launch Java Web Start and the FlashCard game. No need to tell me how awful my artwork is, my daughters already let me know.

Please let me know if you find it interesting or have comments on anything I may have done blatantly wrong, this was my first attempt at a JavaFX application so I am interested in feedback.

Share/Save/Bookmark

JavaFX Example - FlashCard Game

Note: An updated version of the source code for JavaFX 1.1 is available at this post.

I’ve gotten my FlashCard game to a point that is good enough and when I get the chance I’ll post a link to a zip of the contents so you can download it and check it out. Before I do that, I thought I’d take this chance to go over some of things I’ve learned, using my FlashCard application as an example.

My Flashcard game is a simple application that displays flashcards, word side up. Clicking on the Flip Me! button flips the card to show an image of the word. Clicking on the Next button cycles through the deck of cards. Since it is primarily a graphical application, I thought JavaFX would be a good choice for it. This post will go through the files that make up the application, pointing out some of the interesting characteristics of a JavaFX application. (more…)

Share/Save/Bookmark

Learning JavaFX

This is my week off.  I had a nice little vacation planned with the family, but most of the family (except me, so far) has been sick with the flu for the past few days.  We postponed our little jaunt up north but I decided to take the time away from the office anyway.  I needed to keep an eye on the kids while my wife stayed in bed most of the last few days, but I also just needed some time away to do something different.  That something different?  JavaFx, of course.

Ever since the announcement at JavaOne last year I have been curious to check it out.  I was very skeptical about it at first, from what I could tell it looked a lot like Swing but in a scripting language.  I’m still not so sure it isn’t Swing in a scripting language, my old friend, the GridBagLayout is still around after all, but taking a look at it did encourage me to try some things I never really felt like dealing with in regular old Swing.

I decided I’d spend this time on my vacation writing a flash card game for my kids.  You all remember flash cards, right?  This particular version would have words on one side, an image on the other side, and hopefully, if I have time, be slightly enhanced with sound.  I want to encourage my oldest to learn to read phonetically, and I figured a flash card game in which she could click on the individual letters to hear the sounds they make may make it interesting.

I already learned a few things about JavaFX.  One is that it is enough like Java to really confuse me at times since it really isn’t Java and has different syntax.  Another is that some really simple things, like constructors, for example, take entire articles to explain.  I learned that displaying graphics is really easy, but playing a sound file isn’t, at least not until a sound api is incorporated into it.

The coolest thing is that with the NetBeans IDE and the plugin for JavaFX, there is an actual preview window that shows what the JavaFX file will display when it runs.  It also is essential in finding some errors.  It reminds me very much of the Smalltalk workspace in the Smalltalk Visual Studio I used to progam in decades ago.

One downside, though, JavaFX files are script files and they are not compile checked so some errors to not appear until runtime.  And besides that, I don’t think it is possible to debug either, if it is, it isn’t obvious.

Okay, three downsides, number two is that NetBeans will not install on my laptop and doesn’t give a reason why not.  Number three is that the language still seems a bit buggy to me and from what I have read recently, seems that way to others also.  It’s okay, though, I’ve been doing a lot of work with the pre-release versions of ADF 11g so I’m used to dealing with lacking documentation and a plethora of bugs.

I have gotten close to a milestone at this point and if we do end up going away for a few days and my laptop still won’t run NetBeans, I won’t be working anymore on it anytime soon.  I will do my best to provide some type of update, however, before I am back in the thick of things at the office.  It may be that I throw the code up here and let someone else play with it if they are interested.  Only time will tell.

Here are some links to get you started:

JavaFX Community Home 

JavaFX API 

Introduction to JavaFX Script

Share/Save/Bookmark