{
    "content": [
        {
            "type": "text",
            "text": "# tnameserv(1) (man)\n\n**Summary:** tnameserv - Interface Definition Language (IDL).\n\n**Synopsis:** tnameserve -ORBInitialPort [ nameserverport ]\n-ORBInitialPort nameserverport\nThe initial port where the naming service listens for the bootstrap protocol used to\nimplement the ORB resolveinitialreferences and listinitialreferences methods.\n\n## Flags\n\n| Flag | Long | Arg | Description |\n|------|------|-----|-------------|\n| — | — | — | Passes option to the Java Virtual Machine, where option is one of the options described on the reference page for the Ja |\n\n## Examples\n\n- `ADD OBJECTS TO THE NAME SPACE`\n- `The following example shows how to add names to the name space. It is a self-contained`\n- `Transient Naming Service client that creates the following simple tree.`\n- `plans`\n- `Personal`\n- `calendar`\n- `schedule`\n- `In this example, plans is an object reference and Personal is a naming context that contains`\n- `two object references: calendar and schedule.`\n- `import org.omg.CORBA.*;`\n- `import org.omg.CosNaming.*;`\n- `public static void main(String args[]) {`\n- `try {`\n- `In Start the Naming Service, the nameserver was started on port 1050. The following code`\n- `ensures that the client program is aware of this port number.`\n- `Properties props = new Properties();`\n- `props.put(\"org.omg.CORBA.ORBInitialPort\", \"1050\");`\n- `ORB orb = ORB.init(args, props);`\n- `This code obtains the initial naming context and assigns it to ctx. The second line copies`\n- `ctx into a dummy object reference objref that is attached to various names and added into the`\n- `name space.`\n- `NamingContext ctx =`\n- `NamingContextHelper.narrow(`\n- `orb.resolveinitialreferences(\"NameService\"));`\n- `NamingContext objref = ctx;`\n- `This code creates a name plans of type text and binds it to the dummy object reference. plans`\n- `is then added under the initial naming context using the rebind method. The rebind method`\n- `enables you to run this program over and over again without getting the exceptions from using`\n- `the bind method.`\n- `NameComponent nc1 = new NameComponent(\"plans\", \"text\");`\n- `NameComponent[] name1 = {nc1};`\n- `ctx.rebind(name1, objref);`\n- `System.out.println(\"plans rebind successful!\");`\n- `This code creates a naming context called Personal of type directory. The resulting object`\n- `reference, ctx2, is bound to the name and added under the initial naming context.`\n- `NameComponent nc2 = new NameComponent(\"Personal\", \"directory\");`\n- `NameComponent[] name2 = {nc2};`\n- `NamingContext ctx2 = ctx.bindnewcontext(name2);`\n- `System.out.println(\"new naming context added..\");`\n- `The remainder of the code binds the dummy object reference using the names schedule and`\n- `calendar under the Personal naming context (ctx2).`\n- `NameComponent nc3 = new NameComponent(\"schedule\", \"text\");`\n- `NameComponent[] name3 = {nc3};`\n- `ctx2.rebind(name3, objref);`\n- `System.out.println(\"schedule rebind successful!\");`\n- `NameComponent nc4 = new NameComponent(\"calender\", \"text\");`\n- `NameComponent[] name4 = {nc4};`\n- `ctx2.rebind(name4, objref);`\n- `System.out.println(\"calender rebind successful!\");`\n- `} catch (Exception e) {`\n- `e.printStackTrace(System.err);`\n- `BROWSING THE NAME SPACE`\n- `The following sample program shoes how to browse the name space.`\n- `import org.omg.CORBA.*;`\n- `import org.omg.CosNaming.*;`\n- `public static void main(String args[]) {`\n- `try {`\n- `In Start the Naming Service, the nameserver was started on port 1050. The following code`\n- `ensures that the client program is aware of this port number.`\n- `Properties props = new Properties();`\n- `props.put(\"org.omg.CORBA.ORBInitialPort\", \"1050\");`\n- `ORB orb = ORB.init(args, props);`\n- `The following code obtains the initial naming context.`\n- `NamingContext nc =`\n- `NamingContextHelper.narrow(`\n- `orb.resolveinitialreferences(\"NameService\"));`\n- `The list method lists the bindings in the naming context. In this case, up to 1000 bindings`\n- `from the initial naming context will be returned in the BindingListHolder; any remaining`\n- `bindings are returned in the BindingIteratorHolder.`\n- `BindingListHolder bl = new BindingListHolder();`\n- `BindingIteratorHolder blIt= new BindingIteratorHolder();`\n- `nc.list(1000, bl, blIt);`\n- `This code gets the array of bindings out of the returned BindingListHolder. If there are no`\n- `bindings, then the program ends.`\n- `Binding bindings[] = bl.value;`\n- `if (bindings.length == 0) return;`\n- `The remainder of the code loops through the bindings and prints outs the names.`\n- `for (int i=0; i < bindings.length; i++) {`\n- `// get the object reference for each binding`\n- `org.omg.CORBA.Object obj = nc.resolve(bindings[i].bindingname);`\n- `String objStr = orb.objecttostring(obj);`\n- `int lastIx = bindings[i].bindingname.length-1;`\n- `// check to see if this is a naming context`\n- `if (bindings[i].bindingtype == BindingType.ncontext) {`\n- `System.out.println(\"Context: \" +`\n- `bindings[i].bindingname[lastIx].id);`\n- `} else {`\n- `System.out.println(\"Object: \" +`\n- `bindings[i].bindingname[lastIx].id);`\n- `} catch (Exception e) {`\n- `e.printStackTrace(System.err)`\n\n## See Also\n\n- orbd(1)\n\n## Section Outline\n\n- **NAME** (2 lines)\n- **SYNOPSIS** (7 lines)\n- **DESCRIPTION** (35 lines) — 7 subsections\n  - tnameserv -ORBInitialPort nameserverport& (6 lines)\n  - tnameserv -ORBInitialPort 1050& (2 lines)\n  - start tnameserv -ORBInitialPort 1050 (16 lines)\n  - -ORBInitialHost (10 lines)\n  - tnameserv -ORBInitialPort 1050 (2 lines)\n  - java Server -ORBInitialPort 1050 -ORBInitialHost nameserverh (2 lines)\n  - java Client -ORBInitialPort 1050 -ORBInitialHost nameserverh (6 lines)\n- **OPTIONS** (1 lines) — 1 subsections\n  - -J_option_ (4 lines)\n- **EXAMPLES** (4 lines) — 5 subsections\n  - Initial Naming Context (8 lines)\n  - import java.util.Properties; (2 lines)\n  - public class NameClient { (58 lines)\n  - import java.util.Properties; (2 lines)\n  - public class NameClientList { (53 lines)\n- **SEE ALSO** (5 lines)\n\n## Full Content\n\n### NAME\n\ntnameserv - Interface Definition Language (IDL).\n\n### SYNOPSIS\n\ntnameserve -ORBInitialPort [ nameserverport ]\n\n\n-ORBInitialPort nameserverport\nThe initial port where the naming service listens for the bootstrap protocol used to\nimplement the ORB resolveinitialreferences and listinitialreferences methods.\n\n### DESCRIPTION\n\nJava IDL includes the Object Request Broker Daemon (ORBD). ORBD is a daemon process that\ncontains a Bootstrap Service, a Transient Naming Service, a Persistent Naming Service, and a\nServer Manager. The Java IDL tutorials all use ORBD, but you can substitute the tnameserv\ncommand for the orbd command in any of the examples that use a Transient Naming Service.\n\nSee orbd(1) or Naming Service at\nhttp://docs.oracle.com/javase/8/docs/technotes/guides/idl/jidlNaming.html\n\nThe CORBA Common Object Services (COS) Naming Service provides a tree-structure directory for\nobject references similar to a file system that provides a directory structure for files. The\nTransient Naming Service provided with Java IDL, tnameserv, is a simple implementation of the\nCOS Naming Service specification.\n\nObject references are stored in the name space by name and each object reference-name pair is\ncalled a name binding. Name bindings can be organized under naming contexts. Naming contexts\nare name bindings and serve the same organizational function as a file system subdirectory.\nAll bindings are stored under the initial naming context. The initial naming context is the\nonly persistent binding in the name space. The rest of the name space is lost when the Java\nIDL naming service process stops and restarts.\n\nFor an applet or application to use COS naming, its ORB must know the port of a host running\na naming service or have access to an initial naming context string for that naming service.\nThe naming service can either be the Java IDL naming service or another COS-compliant naming\nservice.\n\nSTART THE NAMING SERVICE\nYou must start the Java IDL naming service before an application or applet that uses its\nnaming service. Installation of the Java IDL product creates a script (Oracle Solaris:\ntnameserv) or executable file (Windows: tnameserv.exe) that starts the Java IDL naming\nservice. Start the naming service so it runs in the background.\n\nIf you do not specify otherwise, then the Java IDL naming service listens on port 900 for the\nbootstrap protocol used to implement the ORB resolveinitialreferences and\nlistinitialreferences methods, as follows:\n\n#### tnameserv -ORBInitialPort nameserverport&\n\nIf you do not specify the name server port, then port 900 is used by default. When running\nOracle Solaris software, you must become the root user to start a process on a port below\n1024. For this reason, it is recommended that you use a port number greater than or equal to\n1024. To specify a different port, for example, 1050, and to run the naming service in the\nbackground, from a UNIX command shell, enter:\n\n#### tnameserv -ORBInitialPort 1050&\n\nFrom an MS-DOS system prompt (Windows), enter:\n\n#### start tnameserv -ORBInitialPort 1050\n\nClients of the name server must be made aware of the new port number. Do this by setting the\norg.omg.CORBA.ORBInitialPort property to the new port number when you create the ORB object.\n\nRUN THE SERVER AND CLIENT ON DIFFERENT HOSTS\nIn most of the Java IDL and RMI-IIOP tutorials, the naming service, server, and client are\nall running on the development machine. In real-world deployment, the client and server\nprobably run on different host machines from the Naming Service.\n\nFor the client and server to find the Naming Service, they must be made aware of the port\nnumber and host on which the naming service is running. Do this by setting the\norg.omg.CORBA.ORBInitialPort and org.omg.CORBA.ORBInitialHost properties in the client and\nserver files to the machine name and port number on which the Naming Service is running. An\nexample of this is shown in Getting Started Using RMI-IIOP at\nhttp://docs.oracle.com/javase/8/docs/technotes/guides/rmi-iiop/rmiiiopexample.html\n\nYou could also use the command-line options -ORBInitialPort nameserverport# and\n\n#### -ORBInitialHost\n\nservice. For one example of doing this using the command-line option, see Java IDL: The Hello\nWorld Example on Two Machines at\nhttp://docs.oracle.com/javase/8/docs/technotes/guides/idl/tutorial/jidl2machines.html\n\nFor example, suppose the Transient Naming Service, tnameserv is running on port 1050 on host\nnameserverhost. The client is running on host clienthost, and the server is running on host\nserverhost.\n\nStart tnameserv on the host nameserverhost:\n\n#### tnameserv -ORBInitialPort 1050\n\nStart the server on the serverhost:\n\n#### java Server -ORBInitialPort 1050 -ORBInitialHost nameserverhost\n\nStart the client on the clienthost:\n\n#### java Client -ORBInitialPort 1050 -ORBInitialHost nameserverhost\n\nSTOP THE NAMING SERVICE\nTo stop the Java IDL naming service, use the relevant operating system command, such as kill\nfor a Unix process or Ctrl+C for a Windows process. The naming service continues to wait for\ninvocations until it is explicitly shut down. Note that names registered with the Java IDL\nnaming service disappear when the service is terminated.\n\n### OPTIONS\n\n#### -J_option_\n\nPasses option to the Java Virtual Machine, where option is one of the options\ndescribed on the reference page for the Java application launcher. For example, -J-\nXms48m sets the startup memory to 48 MB. See java(1).\n\n### EXAMPLES\n\nADD OBJECTS TO THE NAME SPACE\nThe following example shows how to add names to the name space. It is a self-contained\nTransient Naming Service client that creates the following simple tree.\n\n#### Initial Naming Context\n\nplans\nPersonal\ncalendar\nschedule\n\nIn this example, plans is an object reference and Personal is a naming context that contains\ntwo object references: calendar and schedule.\n\n#### import java.util.Properties;\n\nimport org.omg.CORBA.*;\nimport org.omg.CosNaming.*;\n\n#### public class NameClient {\n\npublic static void main(String args[]) {\ntry {\n\nIn Start the Naming Service, the nameserver was started on port 1050. The following code\nensures that the client program is aware of this port number.\n\nProperties props = new Properties();\nprops.put(\"org.omg.CORBA.ORBInitialPort\", \"1050\");\nORB orb = ORB.init(args, props);\n\nThis code obtains the initial naming context and assigns it to ctx. The second line copies\nctx into a dummy object reference objref that is attached to various names and added into the\nname space.\n\nNamingContext ctx =\nNamingContextHelper.narrow(\norb.resolveinitialreferences(\"NameService\"));\nNamingContext objref = ctx;\n\nThis code creates a name plans of type text and binds it to the dummy object reference. plans\nis then added under the initial naming context using the rebind method. The rebind method\nenables you to run this program over and over again without getting the exceptions from using\nthe bind method.\n\nNameComponent nc1 = new NameComponent(\"plans\", \"text\");\nNameComponent[] name1 = {nc1};\nctx.rebind(name1, objref);\nSystem.out.println(\"plans rebind successful!\");\n\nThis code creates a naming context called Personal of type directory. The resulting object\nreference, ctx2, is bound to the name and added under the initial naming context.\n\nNameComponent nc2 = new NameComponent(\"Personal\", \"directory\");\nNameComponent[] name2 = {nc2};\nNamingContext ctx2 = ctx.bindnewcontext(name2);\nSystem.out.println(\"new naming context added..\");\n\nThe remainder of the code binds the dummy object reference using the names schedule and\ncalendar under the Personal naming context (ctx2).\n\nNameComponent nc3 = new NameComponent(\"schedule\", \"text\");\nNameComponent[] name3 = {nc3};\nctx2.rebind(name3, objref);\nSystem.out.println(\"schedule rebind successful!\");\nNameComponent nc4 = new NameComponent(\"calender\", \"text\");\nNameComponent[] name4 = {nc4};\nctx2.rebind(name4, objref);\nSystem.out.println(\"calender rebind successful!\");\n} catch (Exception e) {\ne.printStackTrace(System.err);\n}\n}\n}\n\n\nBROWSING THE NAME SPACE\nThe following sample program shoes how to browse the name space.\n\n#### import java.util.Properties;\n\nimport org.omg.CORBA.*;\nimport org.omg.CosNaming.*;\n\n#### public class NameClientList {\n\npublic static void main(String args[]) {\ntry {\n\nIn Start the Naming Service, the nameserver was started on port 1050. The following code\nensures that the client program is aware of this port number.\n\nProperties props = new Properties();\nprops.put(\"org.omg.CORBA.ORBInitialPort\", \"1050\");\nORB orb = ORB.init(args, props);\n\nThe following code obtains the initial naming context.\n\nNamingContext nc =\nNamingContextHelper.narrow(\norb.resolveinitialreferences(\"NameService\"));\n\nThe list method lists the bindings in the naming context. In this case, up to 1000 bindings\nfrom the initial naming context will be returned in the BindingListHolder; any remaining\nbindings are returned in the BindingIteratorHolder.\n\nBindingListHolder bl = new BindingListHolder();\nBindingIteratorHolder blIt= new BindingIteratorHolder();\nnc.list(1000, bl, blIt);\n\nThis code gets the array of bindings out of the returned BindingListHolder. If there are no\nbindings, then the program ends.\n\nBinding bindings[] = bl.value;\nif (bindings.length == 0) return;\n\nThe remainder of the code loops through the bindings and prints outs the names.\n\nfor (int i=0; i < bindings.length; i++) {\n// get the object reference for each binding\norg.omg.CORBA.Object obj = nc.resolve(bindings[i].bindingname);\nString objStr = orb.objecttostring(obj);\nint lastIx = bindings[i].bindingname.length-1;\n// check to see if this is a naming context\nif (bindings[i].bindingtype == BindingType.ncontext) {\nSystem.out.println(\"Context: \" +\nbindings[i].bindingname[lastIx].id);\n} else {\nSystem.out.println(\"Object: \" +\nbindings[i].bindingname[lastIx].id);\n}\n}\n} catch (Exception e) {\ne.printStackTrace(System.err)\n}\n}\n}\n\n### SEE ALSO\n\n• orbd(1)\n\n\n\nJDK 8                                     21 November 2013                              tnameserv(1)\n\n"
        }
    ],
    "structuredContent": {
        "command": "tnameserv",
        "section": "1",
        "mode": "man",
        "summary": "tnameserv - Interface Definition Language (IDL).",
        "synopsis": "tnameserve -ORBInitialPort [ nameserverport ]\n-ORBInitialPort nameserverport\nThe initial port where the naming service listens for the bootstrap protocol used to\nimplement the ORB resolveinitialreferences and listinitialreferences methods.",
        "flags": [
            {
                "flag": "",
                "long": null,
                "arg": null,
                "description": "Passes option to the Java Virtual Machine, where option is one of the options described on the reference page for the Java application launcher. For example, -J- Xms48m sets the startup memory to 48 MB. See java(1)."
            }
        ],
        "examples": [
            "ADD OBJECTS TO THE NAME SPACE",
            "The following example shows how to add names to the name space. It is a self-contained",
            "Transient Naming Service client that creates the following simple tree.",
            "plans",
            "Personal",
            "calendar",
            "schedule",
            "In this example, plans is an object reference and Personal is a naming context that contains",
            "two object references: calendar and schedule.",
            "import org.omg.CORBA.*;",
            "import org.omg.CosNaming.*;",
            "public static void main(String args[]) {",
            "try {",
            "In Start the Naming Service, the nameserver was started on port 1050. The following code",
            "ensures that the client program is aware of this port number.",
            "Properties props = new Properties();",
            "props.put(\"org.omg.CORBA.ORBInitialPort\", \"1050\");",
            "ORB orb = ORB.init(args, props);",
            "This code obtains the initial naming context and assigns it to ctx. The second line copies",
            "ctx into a dummy object reference objref that is attached to various names and added into the",
            "name space.",
            "NamingContext ctx =",
            "NamingContextHelper.narrow(",
            "orb.resolveinitialreferences(\"NameService\"));",
            "NamingContext objref = ctx;",
            "This code creates a name plans of type text and binds it to the dummy object reference. plans",
            "is then added under the initial naming context using the rebind method. The rebind method",
            "enables you to run this program over and over again without getting the exceptions from using",
            "the bind method.",
            "NameComponent nc1 = new NameComponent(\"plans\", \"text\");",
            "NameComponent[] name1 = {nc1};",
            "ctx.rebind(name1, objref);",
            "System.out.println(\"plans rebind successful!\");",
            "This code creates a naming context called Personal of type directory. The resulting object",
            "reference, ctx2, is bound to the name and added under the initial naming context.",
            "NameComponent nc2 = new NameComponent(\"Personal\", \"directory\");",
            "NameComponent[] name2 = {nc2};",
            "NamingContext ctx2 = ctx.bindnewcontext(name2);",
            "System.out.println(\"new naming context added..\");",
            "The remainder of the code binds the dummy object reference using the names schedule and",
            "calendar under the Personal naming context (ctx2).",
            "NameComponent nc3 = new NameComponent(\"schedule\", \"text\");",
            "NameComponent[] name3 = {nc3};",
            "ctx2.rebind(name3, objref);",
            "System.out.println(\"schedule rebind successful!\");",
            "NameComponent nc4 = new NameComponent(\"calender\", \"text\");",
            "NameComponent[] name4 = {nc4};",
            "ctx2.rebind(name4, objref);",
            "System.out.println(\"calender rebind successful!\");",
            "} catch (Exception e) {",
            "e.printStackTrace(System.err);",
            "BROWSING THE NAME SPACE",
            "The following sample program shoes how to browse the name space.",
            "import org.omg.CORBA.*;",
            "import org.omg.CosNaming.*;",
            "public static void main(String args[]) {",
            "try {",
            "In Start the Naming Service, the nameserver was started on port 1050. The following code",
            "ensures that the client program is aware of this port number.",
            "Properties props = new Properties();",
            "props.put(\"org.omg.CORBA.ORBInitialPort\", \"1050\");",
            "ORB orb = ORB.init(args, props);",
            "The following code obtains the initial naming context.",
            "NamingContext nc =",
            "NamingContextHelper.narrow(",
            "orb.resolveinitialreferences(\"NameService\"));",
            "The list method lists the bindings in the naming context. In this case, up to 1000 bindings",
            "from the initial naming context will be returned in the BindingListHolder; any remaining",
            "bindings are returned in the BindingIteratorHolder.",
            "BindingListHolder bl = new BindingListHolder();",
            "BindingIteratorHolder blIt= new BindingIteratorHolder();",
            "nc.list(1000, bl, blIt);",
            "This code gets the array of bindings out of the returned BindingListHolder. If there are no",
            "bindings, then the program ends.",
            "Binding bindings[] = bl.value;",
            "if (bindings.length == 0) return;",
            "The remainder of the code loops through the bindings and prints outs the names.",
            "for (int i=0; i < bindings.length; i++) {",
            "// get the object reference for each binding",
            "org.omg.CORBA.Object obj = nc.resolve(bindings[i].bindingname);",
            "String objStr = orb.objecttostring(obj);",
            "int lastIx = bindings[i].bindingname.length-1;",
            "// check to see if this is a naming context",
            "if (bindings[i].bindingtype == BindingType.ncontext) {",
            "System.out.println(\"Context: \" +",
            "bindings[i].bindingname[lastIx].id);",
            "} else {",
            "System.out.println(\"Object: \" +",
            "bindings[i].bindingname[lastIx].id);",
            "} catch (Exception e) {",
            "e.printStackTrace(System.err)"
        ],
        "see_also": [
            {
                "name": "orbd",
                "section": "1",
                "url": "https://www.chedong.com/phpMan.php/man/orbd/1/json"
            }
        ],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 7,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 35,
                "subsections": [
                    {
                        "name": "tnameserv -ORBInitialPort nameserverport&",
                        "lines": 6
                    },
                    {
                        "name": "tnameserv -ORBInitialPort 1050&",
                        "lines": 2
                    },
                    {
                        "name": "start tnameserv -ORBInitialPort 1050",
                        "lines": 16
                    },
                    {
                        "name": "-ORBInitialHost",
                        "lines": 10
                    },
                    {
                        "name": "tnameserv -ORBInitialPort 1050",
                        "lines": 2
                    },
                    {
                        "name": "java Server -ORBInitialPort 1050 -ORBInitialHost nameserverhost",
                        "lines": 2
                    },
                    {
                        "name": "java Client -ORBInitialPort 1050 -ORBInitialHost nameserverhost",
                        "lines": 6
                    }
                ]
            },
            {
                "name": "OPTIONS",
                "lines": 1,
                "subsections": [
                    {
                        "name": "-J_option_",
                        "lines": 4
                    }
                ]
            },
            {
                "name": "EXAMPLES",
                "lines": 4,
                "subsections": [
                    {
                        "name": "Initial Naming Context",
                        "lines": 8
                    },
                    {
                        "name": "import java.util.Properties;",
                        "lines": 2
                    },
                    {
                        "name": "public class NameClient {",
                        "lines": 58
                    },
                    {
                        "name": "import java.util.Properties;",
                        "lines": 2
                    },
                    {
                        "name": "public class NameClientList {",
                        "lines": 53
                    }
                ]
            },
            {
                "name": "SEE ALSO",
                "lines": 5,
                "subsections": []
            }
        ]
    }
}