Deploying and Running the Solution
Now that you've completed the code, you must deploy and test it in a production environment. The Java Runtime Environment (JRE) and the .NET Framework are required, of course, as well as the C/C++ runtime against which your JNI library was linked.
You must register the .NET assembly so that the path to the assembly can be resolved, or installed the assembly into the GAC. This procedure was discussed earlier in the section "Designing the .NET Control
Install the JNI library into a directory listed in the target machine's PATH
environment variable. If you prefer to keep all the application files together in a single directory, you should either add the current working directory (represented by ".") or your application installation directory to the PATH
environment variable, or change the lookup paths in the command line shown below used to start the Java application:
java.exe -Djava.library.path=".;%PATH%" -classpath
The command line ensures that the current working directory is included in the search path for any native libraries required by the JVM. Adding the current working directory to the CLASSPATH
also ensures that the the JVM can find the Java application class files. See the Sun Java Web site
for more information about deploying and executing Java classes.
Setting up your C/C++ project correctly allows you to compile and debug your native C/C++ code and your .NET code in whatever language you use. The sample project is configured to run the Java application using the command line above. You could instead use the jdb.exe
application to debug the Java application at the same time.
When you have completed your testing plan, you should recompile your entire source in a release build and deploy the solution in the same way described above.
Although the process to host .NET controls in Java isn't trivial, being able to use the rich user interfaces and technologies in .NET within your Java application is advantageous. You can reuse your .NET controls in both .NET and Java applications and can potentially reduce the development time of producing and maintaining separate class libraries in different languages.