The project
The project is a large C# project which is used for test-automation. For this purpose i've to use a java-tool which is the tool which saves all results into a file which can be loaded into a test-environment.
The interface
I got a DLL from the vendor of the test-environment which is build in C++, this dll loads the java environment and loads the jar files.
Current situation
The java environment is loaded with success, its configured with environment-variables set in C# with this method:
String java = GetJavaInstallationPath();
Environment.SetEnvironmentVariable("PATH", String.Format("{0};{1}", Environment.GetEnvironmentVariable("PATH"), Path.Combine(java, @"bin\client")), EnvironmentVariableTarget.Process);
After this i set the path to the java classes using this code:
Environment.SetEnvironmentVariable("ITEPCLASSPATH",
String.Format("{0};{1}",
Path.Combine(iTepPath, "itep.jar"),
Path.Combine(iTepPath, "libs\\itorx.jar")), EnvironmentVariableTarget.Process);
Which actually should work, it shows the correct value when using Environment.GetEnvironmentVariable("ITEPCLASSPATH") but the C++-DLL tells me that it isn't working.
When setting the class path by using a external bat-file it works. Some more facts:
- The application is started by the bat file
- The path is copied from my generated path of the dll
- I don't comment anything out, so the path is still set by C#
It seems that java is not accessing the env.-variable i set in C# but recognizes that i set it in the bat file.
I really need to set the variable via C#, how do i archive this?
System.IO.Process.Start. Do you really need to use the DLL? Otherwise, try to find out how the environment gets passed through dlls. I can't see why it doesn't work. I think it should.LoadLibraryafter i set all the variables.