Java runtime properties

An EGL-generated Java™ program uses a set of runtime properties that provide information such as how to access the databases and files that are used by the program.

For details on the runtime properties used by a service generated with EGL, see Library part of type ServiceBindingLibrary.

In a J2EE environment

In relation to a generated Java program that will run in a J2EE environment, these situations are possible:
  • EGL can generate the runtime properties directly into a J2EE deployment descriptor. In this case, EGL overwrites properties that already exist and appends properties that do not exist. The program accesses the J2EE deployment descriptor at run time.
  • Alternatively, EGL can generate the runtime properties into a J2EE environment file. You can customize the properties in that file, then copy them into the J2EE deployment descriptor.
  • You can avoid generating the runtime properties at all, in which case you must write any needed properties by hand.

In a J2EE module, every program has the same runtime properties because all code in the module shares the same deployment descriptor.

In WebSphere® Application Server, properties are specified as env-entry tags in the web.xml file that is associated with the Web project, as in these examples:
  <env-entry>
		  <env-entry-name>vgj.nls.code</env-entry-name>
    <env-entry-value>ENU</env-entry-value>
    <env-entry-type>java.lang.String</env-entry-type>
  </env-entry>

  <env-entry>
    <env-entry-name>vgj.nls.number.decimal</env-entry-name>
    <env-entry-value>.</env-entry-value>
    <env-entry-type>java.lang.String</env-entry-type>
  </env-entry>

In a non-J2EE Java environment

In relation to a generated Java program that runs outside of a J2EE environment, you can generate the runtime properties into a program properties file or code that file by hand. (The program properties file provides the kind of information that is available in the deployment descriptor, but the format of the properties is different.)

In a non-J2EE Java environment, properties can be specified in any of several properties files, which are searched in this order:
  • user.properties
  • A file named as follows--
      programName.properties
    programName
    The first program in the run unit
  • rununit.properties

Use of user.properties is appropriate when you specify properties that are specific to a user. EGL does not generate content for this file.

Use of rununit.properties is especially appropriate when the first program of a run unit does not access a file or database but calls programs that do:
  • When generating the caller, you can generate a properties file named for the program, and the content might include no database- or file-related properties
  • When you generate the called program, you can generate rununit.properties, and the content would be available for both programs

None of those files is mandatory, and simple programs do not need any.

At deployment time, these rules apply:
  • The user properties file ( user.properties, if present) is in the user home directory, as determined by the Java system property user.home.
  • The location of a program properties file (if present) depends on whether the program is in a package. The rules are best illustrated by example:
    • If program P is in package x.y.z and is deployed to MyProject/JavaSource, the program properties file must be in MyProject/JavaSource/x/y/z
    • If program P is not in a package and is deployed to myProject/JavaSource, the program properties file (like the global properties file) must be in MyProject/JavaSource

    In either case, MyProject/JavaSource must be in the classpath.

  • The global properties file (rununit.properties, if present) must be with the program, in a directory that is specified in the classpath.

If you generate output to a Java project, EGL places the properties files (other than user.properties) in the appropriate folders.

If you are generating Java code for use in the same run-unit as Java code generated with an earlier version of EGL or VisualAge® Generator, the rules for deploying properties file depends on whether the first program in the run unit was generated with EGL 6.0 or later (in which case the rules described here apply) or whether the first program was generated with an earlier version of EGL or VisualAge Generator (in which case the properties files can be in any directory in the classpath, and the global file is called vgj.properties).

Finally, if the first program was generated with the earlier software, you can specify an alternate properties file, which is used throughout the run unit in place of any non-global program properties files. For details, see the description of property vgj.properties.file in Java runtime properties (details).

Build descriptors and program properties

Choices are submitted to EGL as build-descriptor-option values:
  • To generate properties into a J2EE deployment descriptor, set J2EE to YES; set genProperties to PROGRAM or GLOBAL; and generate into a J2EE project.
  • To generate properties into a J2EE environment file, set J2EE to YES; set genProperties to PROGRAM or GLOBAL; and do either of these:
    • Generate into a directory (in which case you use the build descriptor option genDirectory rather than genProject); or
    • Generate into a non-J2EE project.
  • To generate a program properties file with the same name as the program being generated, set J2EE to NO; set genProperties to PROGRAM; and generate into a project other than a J2EE project.
  • To generate a program properties file rununit.properties, set J2EE to NO; set genProperties to GLOBAL; and generate into a project other than a J2EE project.
  • To avoid generating properties, set genProperties to NO.

For additional information

For details on generating properties into a deployment descriptor or into a J2EE environment file, see Setting deployment-descriptor values.

For details on the meaning of the runtime properties, see Java runtime properties (details).

For details on accessing runtime properties in your EGL code, see sysLib.getProperty.

Feedback
(C) Copyright IBM Corporation 2000, 2005. All Rights Reserved.