The Oracle JDeveloper IDE

Java developers can choose among several different IDEs. (Integrated Development Environment)

Eclipse and NetBeans are open source software. Each IDE has its strengths and weaknesses. There is IBM behind Eclipse, Sun behind NetBeans and Oracle behind JDeveloper. In this article we will examine JDeveloper. The JDeveloper enables you to develop Java enterprise applications as well as desktop applications. There are two things that I love about JDeveloper. It is its look and feel. It is the best looking IDE. It is written in Swing toolkit. Looks exactly the same on both Windows and Linux. It is slower than Eclipse, but it is quite swift. At least for my test development. (I have not used it extensively.) The other thing that I like is that it comes in three different editions. The studio edition, the j2ee edition and the java edition. The basic java edition contains only the core Java and XML features. This was exactly what I needed. Why install features you will never use? The size of the download is smaller (currently 55 MB) and the application is more responsive.

Installation

First we download the JDeveloper IDE from the official download page. We must go through registration process to access the download file. It is a bit annoying. Especially, when you want to upgrade your version and you have forgotten your password or login. (or both). I am lost in all those logins and passwords. At home, at work, on the web. The current version is 10.1.3.2. It was released in January 2007. I have downloaded the basic java edition. It is perfect for my development of small desktop applications in Java and Swing. There are also three install types. Windows, Mac and universal base install. I work on Linux, so I have chosen the base install. It works on all platforms. The other two are probably optimized for those two platforms. I assume. The download file name is jdevjavabase10132.zip. We unzip the file to our preferred directory. Let's say ~/jdeveloper. Now we can lauch the JDeveloper IDE. The startup file is in the ~/jdeveloper/jdev/bin directory.

./jdev

When we first launch the JDeveloper, it will ask for the path to the Java jdk directory. Type the full pathname of a J2SE installation (or Ctrl-C to quit), the path will be stored in ~/.jdev_jdk

On my system it is /home/vronskij/bin/jdk1.6.0_01. The path will be stored in the hidden .jdev_jdk file name located in the home directory. Then we should see this splashscreen.

JDeveloper splashscreen
JDeveloper splashscreen

Whoops. A dialog window pops up.

JDeveloper

The problem is that I have the newest Java jdk1.6. And the JDeveloper is certified to run on the previous one. I have never encountered any problems regarding this issue. And there is a certain progress from the previous version of JDeveloper. We can grab the dialog box from behind the splashscreen. And click the skip message option.

Now we have been rewarded for our patience and hard work and we have the JDeveloper in full beauty. Ok. One more step. Close the Tip of the day dialog box. And do not forget to unclick the Show tips on startup box. Here we have a screenshot of our beautiful Oracle JDeveloper IDE version 10.1.3.2.0.

The Oracle JDeveloper screenshot
Oracle JDeveloper IDE

Creating a Swing application

I like this JDeveloper slim release, because the creation process is quite simple. (On the other hand, it could be even simpler.) Comparing to other IDE's it is. We do not have to go through all those enterprise apps, beans, libs and the like. We go to File menu, click New. Then we select Application. We give an application a name. In the next dialog window, we provide a name for a project that will host our application. We then go to the System Navigator. Select the project. Right click on the project name, select New Class. We are ready to start coding our Java Swing application.

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.image.CropImageFilter;
import java.awt.image.FilteredImageSource;

import javax.swing.Box;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;


public class Puzzle extends JFrame implements ActionListener {

    private JPanel centerPanel;
    private JButton button;
    private JLabel label;
    private Image source;
    private Image image;
    int[][] pos;

    public Puzzle() {

        pos = new int[][] {
                            {0, 1, 2}, 
                            {3, 4, 5}, 
                            {6, 7, 8}, 
                            {9, 10, 11}
                        };


        centerPanel = new JPanel();
        centerPanel.setLayout(new GridLayout(4, 4, 0, 0));

        ImageIcon sid = new ImageIcon(Puzzle.class.getResource("icesid.jpg"));
        source = sid.getImage();


        add(Box.createRigidArea(new Dimension(0, 5)), BorderLayout.NORTH);    
        add(centerPanel, BorderLayout.CENTER);


        for ( int i = 0; i < 4; i++) {

            for ( int j = 0; j < 3; j++) {

                if ( j == 2 && i == 3) {
                    label = new JLabel("");
                    centerPanel.add(label);

                } else {

                    button = new JButton();
                    button.addActionListener(this);
                    centerPanel.add(button);
                    image = createImage(new FilteredImageSource(source.getSource(),
                        new CropImageFilter(j*103, i*60, 103, 60)));
                    button.setIcon(new ImageIcon(image));
                }
            }
        }

        setSize(325, 275);
        setTitle("Puzzle");
        setResizable(false);
        setLocationRelativeTo(null);
        setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        setVisible(true);
    }


    public static void main(String[] args) {

        new Puzzle();

    }

    public void actionPerformed(ActionEvent e) {
        JButton button = (JButton) e.getSource();
        Dimension size = button.getSize();

        int labelX = label.getX();
        int labelY = label.getY();
        int buttonX = button.getX();
        int buttonY = button.getY();
        int buttonPosX = buttonX / size.width;
        int buttonPosY = buttonY / size.height;
        int buttonIndex = pos[buttonPosY][buttonPosX];



        if (labelX == buttonX && (labelY - buttonY) == size.height ) {

             int labelIndex = buttonIndex + 3;

             centerPanel.remove(buttonIndex);
             centerPanel.add(label, buttonIndex);
             centerPanel.add(button,labelIndex);
             centerPanel.validate();
        }

        if (labelX == buttonX && (labelY - buttonY) == -size.height ) {

             int labelIndex = buttonIndex - 3;
             centerPanel.remove(labelIndex);
             centerPanel.add(button,labelIndex);
             centerPanel.add(label, buttonIndex);
             centerPanel.validate();
        }

        if (labelY == buttonY && (labelX - buttonX) == size.width ) {

             int labelIndex = buttonIndex + 1;

             centerPanel.remove(buttonIndex);
             centerPanel.add(label, buttonIndex);
             centerPanel.add(button,labelIndex);
             centerPanel.validate();
        }

        if (labelY == buttonY && (labelX - buttonX) == -size.width ) {

             int labelIndex = buttonIndex - 1;

             centerPanel.remove(buttonIndex);
             centerPanel.add(label, labelIndex);
             centerPanel.add(button,labelIndex);
             centerPanel.validate();
        }
    }
}

We have used a 308x238 px image of Sid. Sid is one of the main characters in the Ice Age movie.