Category Archives: Project

The projects category is for descriptions about current projects.

Preparing for Emigration (1)


Introduction

CDO Office
CDO Office

Yes, it’s coming closer now. Next Sunday I will be airborne and on my way to Cagian de Oro. Why this place? Of all places in the world I chose this place for the following reasons:

  1. My future wife lives there. Actually we met there during my holyday last June.
  2. Nice climate. I don’t like Dutch winters, the shortening of days makes me depressive. There is one known cure: Light therapy but as entrepreneur I cannot afford lying 10 hours per week on a sun bank.
  3. Talented and creative people. When I just look at my fiancé I know enough. It’s truly amazing what she can do with a Samsung Phone. I want to see what she is able to do with Adobe Premiere or Apples Final Cut Pro.
  4. Office in the Open air. Sounds crazy? Not for me. My office has a roof and a bar. Actually it’s a Hotel. Many foreign entrepreneurs have.
  5. Costs of living – Lots cheaper than here! Not just because things cost less. We also don’t have to pay taxes in the Philippines. For the price of a single room here (including income taxes) I can rent 10 rooms over there! It’s a nice place to work in.

Why would you want Java FX?



Introduction

The reasons why you should switch to JavaFX are many. Here are just a few:

  • The GUI has a much more fresh and modern look compared to Swing or AWT. (To me it looks more to MacOS Aqua).
  • Lightweight and hardware accelerated.
  • Easier and faster to develop thanks to Oracle Theme Builder.
  • CSS Support (Desktop and Web).
  • Ready to use GUI Widgets (like the calendar).
  • Accurate and fast positioning of Desktop (and web) widgets.
  • 3D support.
  • Supports a native XML format named FXML. It’s somewhat similar to HTML, Which makes it easy for we developers to work with.

References

 

JavaFX


Introduction

JavaFX is a software platform for creating and delivering desktop applications, as well as rich Internet applications (RIAs) that can run across a wide variety of devices. JavaFX is intended to replace Swing as the standard GUI library for Java SE, but both will be included for the foreseeable future. JavaFX has support for desktop computers and web browsers on Microsoft Windows, Linux, and macOS.

JavaFX
JavaFX

Similar to Eclipse SWT, It’s written for the Desktop and replaces Swing and AWT. Next to the Desktop, JavaFX can also be used to be used with Webbrows.

The code below shows how a Window named ‘HelloWorld’ with a button ‘HelloWorld’ named  is created. When the button is clicked, the console prints Hello World.

package javafxtuts;
 
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;

public class JavaFxTuts extends Application {
    public JavaFxTuts()
    {
        //Optional constructor
    }
    @Override
    public void init()
    {
         //By default this does nothing, but it
         //can carry out code to set up your
         //app.
         //It runs once before the start
         //method and after the constructor.
    }
    
    @Override
    public void start(Stage primaryStage) {
        // Create the Java button
        final Button button = new Button();
        // Setting text to button
        button.setText("Hello World");
        // Registering a handler for button
        button.setOnAction((ActionEvent event) -> {
            // Printing Hello World! to the
            // console
            System.out.println("Hello World!");
        });
        // Please note that this Synax is a
        // Lambda Expression 
        // Initializing the StackPane class
        final StackPane root = new StackPane();
        // Adding all the nodes to the StackPane
        root.getChildren().add(button);
        // Creating a scene object
        final Scene scene = new Scene(root, 300,
         250);
        // Adding the title to the window
        // (primaryStage)
        primaryStage.setTitle("Hello World!");
        primaryStage.setScene(scene);
        // Show the window(primaryStage)
        primaryStage.show();
    }
    @Override
    public void stop()
    {
        //By default this does nothing
        //It runs if the user clicks the 
        //go-away button
        //closing the window or if 
        //Platform.exit() is called.
        //Use Platform.exit() instead of
        //System.exit(0).
        //This is where you should offer to save
        //any unsavedstuff that the user 
        //may have generated.
    }
 
    /**
     * Main function that opens the "Hello
     * World!" window
     * Note that Main starts the execution of the
     * Application, just as in any regular 
     * Java Application.
     * @param args the command line arguments
     */        public static void main(final String[] 
        arguments) {
    // The actual start takes place with the
    //  launch(arguments);
    //  launch(arguments); Command:
        launch(arguments);
    }
}
References and Tutorials

There exist many on the web:

Our Office is soon moving.

Introduction

The people who have read the about page  already know this. The office is going to emigrate from Arnhem  the Netherlands to Cagyan de Oro in the Philippines.

Cagyan de Oro Office
Cagyan de Oro Office

 

Why?

We hope to be able to serve you better and faster with a larger team of professionals and Support Department.

What will change?

Apart from the opening hours you won’t notice anything, except perhaps that we will have different opening hours, work  with a larger team of professionals. We plan to expand with a new service and support Department, a Sales and Marketing department and extended team of professionals.

Technical Writing

I have some Technical writing skills. You can check it out by reading the articles on this site plus the comments from readers. Furthermore I’m experienced in the following niches:

  • Technical Documentation.
  • User Documentation. (Help Files in ,chm, HTML , XML, ePub, Wiki, markdown, postscript and PDF).
  • UML and Design Patterns.
  • Visio, AutoCAD and OmniGraffle technical drawings.
How I can help.
  • Writing your project documentation, Technical Design, Proposals and Solutions Ducuments (High Level and Detailed).
  • Writing Technical Designs and Developer Documents.
  • Setting up, hosting and publishing DocuWiki or MoinMoin Wiki in a VPN. Free for you and your employees to use.
Pricing

I will make a free proposal with fixed price in advance.

The Eclipse Rich Client Platform (RCP)

Introduction

In previous articles I talked about the Standard Widget Toolkit (SWT). There’s more. It’s all part of a bigger plan. The Rich Client Platform (RCP).

To understand the Rich Client we first need to know the normal client. For the RCP Developers the normal client is a Webbrowser. Although Webbrowers have evolved significantly the latest years (AJAX, JavaScript Libraries and performance), a Browser is still a Browser. We can use them to view webpages.

Although the Rich Client can do this too. It’s much more an Application which can run standalone or by using Servers. In this case, the Rich Client is hosted as a Web Application. To get an idea of what’s currently available, visit the Eclipse Rich Client Marketplace. It currently has 1654 Rich Clients and new ones are arriving daily. Most of them are developed using a variant of SWT. The Eclipse Project which is most involved with RCP is the e4 Project.

Apache Axis, real time remote SOAP API’s

Introduction

I wrote about SOA elsewhere in this site. It’s Service Oriented Architecture based on well described services which can be accessed trough the http protocol. This is essential to prevent routers which block all kinds of ports not to prevent our Service Oriented Architecture.

Apache Axis

Axis is yet another fine Apache project which enables us to make services available in a truely amazing easy way! Apache Axis is above all very easy to use since it’s built in in most IDE’s. Eclipse is one of them and creating a Service with Eclipse is really a piece of cake. It’s really as easy as right-clicking a JavaBean and selecting “Generate Web Application”. Eclipse will then take over and go ahead generating the service. Next to the Service it will also generate:

  • A WSDL file.
  • A (JSP based client) to test your service.
  • API Documentation (for the Consumers of your Service).
Creating a Client

In Eclipse this is even more easy. Right click the WSDL and select “Generate Web-Service Client. Eclipse goes to work and produces a skeleton of Java Classes and interfaces which you need to get the client working!

What type of Programs are worth generating services for?

It depends. Do you want to do SOA? Then your service should be as elementary as possible. (Atomic). A generic service could be anything, Database lookups, Conversions and more functions which can be useful for public users.

 

What are JavaBeans?

ejwagenaar.com logo

What are JavaBeans?

According to Wikipedia:

JavaBeans are classes that encapsulate many objects into a single object (the bean). They are serializable, have a zero-argument constructor, and allow access to properties using getter and setter methods. The name “Bean” was given to encompass this standard, which aims to create reusable software components for Java.

According to Evert:

A JavaBean is a normal class with a few properties:

  • Javabeans have a zero argument Constructor. They cannot be instantiated with Data. The data is always added after the instantiation.
  • JavaBeans implement the Serializable interface which make them serializable.
  • All class-members are private.
  • To access data inside the class you need to create so-called ‘Accessor methods’ these are the getters and setters. You can only change the values of the class members by calling setProperty(). The same thing is true to get read the private class-members. This is done by the getters. getProperty().
  • Accessor Methods have a naming convention as follows: Lowecas get or set, followed by the property name (capitalized) so if the bean has a property called id, it’s accessor-methods become getId() and setId().
  • JavaBeans can be serialized.
  • Javabeans know things about theirselves. This is called Introspection.
So what are they used for?

JavaBeans are typically used as data-carriers, for example a JavaBean can be used to represent a Database Table Row, which makes sense in a DAO (Data Access  Object). This is indeed one of the most common applications of JavaBeans.

Utilities
Example of Introspection.

As I already mentioned, JavaBeans can look inside themselves, for example to get the class name:

// Get the fully-qualified name of a class
Class cls = java.lang.String.class;
String name = cls.getName();        // java.lang.String

// Get the fully-qualified name of a inner class
cls = java.util.Map.Entry.class;
name = cls.getName();               // java.util.Map$Entry

// Get the unqualified name of a class
cls = java.util.Map.Entry.class;
name = cls.getName();
if (name.lastIndexOf('.') > 0) {
    name = name.substring(name.lastIndexOf('.')+1);  // Map$Entry
}
// The $ can be converted to a .
name = name.replace('$', '.');      // Map.Entry


// Get the name of a primitive type
name = int.class.getName();         // int

// Get the name of an array
name = boolean[].class.getName();   // [Z
name = byte[].class.getName();      // [B
name = char[].class.getName();      // [C
name = short[].class.getName();     // [S
name = int[].class.getName();       // [I
name = long[].class.getName();      // [J
name = float[].class.getName();     // [F
name = double[].class.getName();    // [D
name = String[].class.getName();    // [Ljava.lang.String;
name = int[][].class.getName();     // [[I

// Get the name of void
cls = Void.TYPE;
name = cls.getName();               // void

A more complex example of Introspection can be found here.

The java.net.URL

ejwagenaar.com logo

 

Introduction

Above everything the Java Programming language was designed to

be a Networking Language by Sun Microsystems early nineties Sun’s slogan was “The Network is the Computer”.

Actually John Gage wasn’t completely right. Although it has become true for some systems   Computers are still the Computer, weather they are smartphones, smart watches, PC’s, Macs, iPads, Android tablets or Virtual Machines are still the real computers. Although they have become more and more connected and serve the API’s which  are accessed trough the networks.

Public API’s are becoming more and more available and are used as services which indeed make the Network. The coming of SOA slowly is making things better.

Time to see how you can connect to a (web) service using the java.net API.

Opening and reading from a url

In java.net the Opbject which represents an url is the URL object. You can instantiate it as follows:

URL url = new URL("http://www.ejwagenaar.com");

The next step is to open a connection:

HTTPUrlConnection con = url.openConnection();

Now we are ready to read from the connection. This is similar to reading from a file:

 

BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
        String inputLine;
        while ((inputLine = in.readLine())
          != null) 
          System.out.println(inputLine);
        in.close();
    }
}

This prints the html of my homepage to the console. If you want to write it to disk, follow the instructions on writing to a file.

As you can see, the methods for java.io are consistent everywhere, which makes the Java programming language easy to learn.

i/o streams should always be closed!!!

Conclusion

This article demonstrates how to make a http connection and read a full HTML page from an HTTP connection using only plain Java objects. In another article we will post something to the http server.