J. Duke | 319a3b9 | 2007-12-01 00:00:00 +0000 | [diff] [blame^] | 1 | This sample provides C# "Hello World" program that is invoked |
| 2 | from Java application in the same process. |
| 3 | |
| 4 | There is no way to invoke .NET methods from Java classes directly, |
| 5 | it is necessary to use native code level. |
| 6 | The sample contains C++ library that can invoke any .NET program by mscorlib library. |
| 7 | Using the JNI the Java application invokes the C# "Hello World". |
| 8 | |
| 9 | The sample contains the following files: |
| 10 | |
| 11 | Makefile - make file |
| 12 | README.txt - this readme |
| 13 | invoked.cs - the invoked HelloWorld Java program |
| 14 | invoker.java - C# invoker application |
| 15 | invoker.cpp - C++ wrapper |
| 16 | invokerExp.h - wrapper library exports |
| 17 | invoker.h - javah generated file with the native method definition |
| 18 | |
| 19 | After the success making the following files are produced: |
| 20 | |
| 21 | invoked.exe - the executable HelloWorld .NET program |
| 22 | invoker.class - the compiled Java class that invokes the .NET program |
| 23 | invoker.dll - the wrapper library |
| 24 | |
| 25 | The following environment needs to be set for the correct sample |
| 26 | build and execution: |
| 27 | |
| 28 | INCLUDE must contain the paths to: |
| 29 | 1. MS Visual C++ standard include |
| 30 | 2. .NET SDK include |
| 31 | 3. Java includes |
| 32 | Example: %MSDEV%/VC98/Include;%DOTNET%/Include;%JAVA_HOME%/include;%JAVA_HOME%/include/win32 |
| 33 | |
| 34 | LIB must contain the paths to: |
| 35 | 1. MS Visual C++ standard libraries |
| 36 | 2. .NET SDK libraries |
| 37 | Example: %MSDEV%/VC98/Lib;%DOTNET%/Lib |
| 38 | |
| 39 | PATH must contain the paths to: |
| 40 | 1. MS Visual C++ standard bin |
| 41 | 2. MS Dev common bin |
| 42 | 3. .NET SDK libraries |
| 43 | 4. Java bin |
| 44 | Example: %MSDEV%/VC98/Bin;%MSDEV%/Common/MSDev98/Bin;%DOTNET%/Lib;%JAVA_HOME%/bin;%PATH% |
| 45 |
|
| 46 | To run the sample please do:
|
| 47 |
|
| 48 | java invoker invoked.exe
|
| 49 |
|
| 50 |
|
| 51 | --Dmitry Ryashchentsev
|