The primary use of the Session API is to provide the parameters so that the rest of the APIs can access the desired Cyc. If no configuration is provided, applications using the Cyc Java APIs will pop up a window asking the user to specify the host and port where a Cyc server can be found. In contexts where no windowing is available, the program will suffer an unrecoverable error and terminate.
A number of mechanisms are available to programatically specify the Cyc server. Here are a few of the simplest. Additional ways to specify the Cyc server will be added as the Session API matures.
Here are two different approaches:
Specify the server at the command line when you start the program:
java -Dcyc.session.server=testserver:3600 […path to jar or classpath]
Specify at the command line a java properties file that contains the relevant parameters:
java -Dcyc.session.configurationFile=props.properties […path to jar or classpath]
Inside your properties file, specify the Cyc server with the property cyc.session.server:
First, an important caveat: There are a number of ways to set a Cyc server from within NetBeans, but many of these approaches store your preferences in a file which is likely to get added to source control. If this happens, it can cause subtle and extremely frustrating bugs for other developers, as they blindly run tests from their checkout against the server address you’ve specified. The following approaches avoid that problem.
This will set a set a Cyc server which will be used by all projects in your NetBeans IDE:
That’s it! Note that individual projects cannot override this setting. So long as a project is being run in NetBeans, it will use this Cyc server. Of course, you can always edit or remove the value from the Global Execution Options field.
This will set a Cyc server to be used by a single project:
Then, in the Add configuration dialog:
Now, with your profile highlighted, click the Activate button. Then click Okay to exit the Project Properties dialog.
That’s it! From now on, your custom configuration should be used by default, and the Cyc Core APIs should automatically use the server you specified. Note that a project-specific address will not override a global address.
To change a project-specific Cyc server address: