Category: Java/.NET Runtime
Is the system CLASSPATH used by my mixed Java/.NET application?
No. It's simply too dangerous to rely on the correct setup of the system classpath. Most production-quality Java applications configure their classpath in a startup script or batchfile. We did not want to force you to do this and consequently gave you have many ways to configure the classpath used by your .NET application, but if you're set on using the CLASSPATH, there are two ways you can do it.
The first option involves using a framework-recognized environment variable called XMOG_CLASSPATH. Simply set XMOG_CLASSPATH to the value of CLASSPATH and initialize your application so that it accepts environment variable overrides. The following snippet shows how to do this:
IJvmLoader loader = JvmLoader.GetJvmLoader( true, ... )
The key is to pass true as the first argument to the JVM loader factory method. This tells the runtime library that it should analyze the environment to look for variables that provide runtime settings. Please don't rely on a globally set XMOG_CLASSPATH environment variable. If you ever deploy more than one application that uses proxy classes and the two applications have conflicting classpath requirements, you're going to break one of them.
The second option involves simply doing it in code. There's nothing preventing you from reading the value of CLASSPATH in your application and using its value as an initialization argument. The following snippet illustrates this approach:
IJvmLoader loader = JvmLoader.GetJvmLoader(); string cp = Environment.GetEnvironmentVariable( "CLASSPATH" ); if( cp != null ) loader.ClassPath = cp;
As you can see, you can easily write your own initialization logic using a combination of built-in and custom techniques.