Tag Archive: registry

The registry on the JNIOR is what defines how it is configured. Registry keys hold information that persist past reboots, allowing applications to set them and save settings that have been created. This information can be connection settings, device identification, versioning, etc. Below is a quick example that prints out a specific registry key’s information, and then prompts the user to enter a new value for it. 

In this example the registry key being referenced on the JNIOR called AppData/RegistyTest. This registry key doesn’t exist the first time the application is run, and it will print out “Registry not created yet”. It will then prompt the user to enter a value for it, and once that’s done it will exit the application. Running the application a second time will show that the value entered for the registry key will now be what’s displayed for its value.

View on GitHub

I put the built jar file of this example application into the JNIOR’s flash folder and ran it from the Web UI’s console tab. As you can see it, the registry key report empty the first the application is run, and the second time its run the registry key contains the value enter for it the first time it was run.

Here shows the registry key we created in the Registry Tab of the JNIOR Web UI.

Applications receive command line arguments just as any standard Java program would. You can use these to establish new default configuration settings. For example we are developing a UI for our Cinema application. The UI application (called “Cinekey” right now) when run makes a TCP/IP connection to a host running the Cinema application. By default localhost is used and the default port is 9610.

The command line syntax is:

cineky [Ip_address [port]]

You can even include these parameters in a Run key. If the optional host Ip_address is specified it will be recorded as the new default. If you specify the host you can also optionally specify the port. That will also be save as default. That means that if you do that once then you can just use the program name from that point forward to run it and it will use the last specified socket default.

Here is the code for that. You can see how it can be adapted perhaps to your configuration needs.

    public static void main(String[] args) throws Throwable {
        String host = "";
        int port;
        // obtain port
        if (args.length > 1) {
            port = Integer.parseInt(args[1]);
            JANOS.setRegistryString("Cinekey/Port", Integer.toString(port));
            port = JANOS.getRegistryInt("Cinekey/Port", 9610);
        // Obtain host
        if (args.length > 0) {
            host = args[0];
            JANOS.setRegistryString("Cinekey/Host", host);
            host = JANOS.getRegistryString("Cinekey/Host", "localhost");
        // Establish connection
        conn = new CineConnect(host, port);
        new Thread(conn).start();