Note that there are some explanatory texts on larger screens.

plurals
  1. POProgram uses outdated (not current) env variable value
    primarykey
    data
    text
    <p>I've got a C++ program that internally uses java (via my C++ dll that wrapps the WebLogic jsmc.dll that internally uses jvm.dll).</p> <p>When I set CLASSPATH before running my program, all JAR libraries are found and the program works properly. When I do <strong>not</strong> set the CLASSPATH before running my program, the JARs are <strong>not</strong> found, which of course is expected.</p> <p>Now, when I set the CLASSPATH before running my program, but <strong>clear</strong> this CLASSPATH environment variable inside the program code <strong>before</strong> loading my dll that uses java, a strange thing happens: all JARs are still found and the program works as if everything was OK. I have verified by several ways that the CLASSPATH is really deleted from the env variables (e.g. by using ProcessExplorer or by printing its value).</p> <p>QUESTION:</p> <p>Can you explain this behaviour to me? I'm <strong>not</strong> wondering why java ignores the CLASSPATH I set, but <strong>how is it possible</strong> that java sees the old CLASSPATH value, not the current one? I emphasize that it isn't possible for java to store the old CLASSPATH value somehow because java was not loaded at the the time the old value was available.</p> <p>How can I make the java to respect the changes in the process env variables?</p> <p>DETAILS:</p> <p>The problem above is just a simplification I've made to explore my real problem. I'm trying to set the CLASSPATH from within the program and avoid to have it set externally. But the java uses the externally set CLASSPATH, not the one I set inside the program.</p> <p>I read and set the env variables values using the Windows API (GetEnvironmentVariableA, SetEnvironmentVariableA). I have verified that the program process environment variables really change after setting them this way. I even printed the CLASSPATH value from the dll that uses java, before calling any java method. I checked using the ProcessMonitor that jvm.dll is really loaded <strong>after</strong> the CLASSPATH is deleted. I also tried to exclude the possibility that the CLASSPATH is read from the parent process. Now I'm pretty sure that at the time jvm.dll is being loaded, the CLASSPATH is already deleted from the process environment.</p> <p>I have tried both a Visual C++ 2010 testing program and the HP LoadRunner C-compiler (mmdrv.exe) vuser script, with the same result. LoadRunner is the main reason why I need to solve this problem.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload