This is the mail archive of the cygwin mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Problem to retrieve environment variable values in JVM when Cygwin prompt is used


We use Cygwin build and its command prompt in our use cases. 
Currently, We are facing a problem to retrieve environment variable values in JVM program. Please find details of issue below :

Version details : Currently, cygwin1.7.33 is being used on windows (tried on server 2008R2, server 2012) platform. 

Files attached with this mail :
1. SampleJVM.cpp ==> C program which evokes JVM and it calls a java method
2. and TestEnvironmentVariables.class ==> Java program containing a method to print environment variables.

Precautions :
1. Ensure that jdk is installed on the system. 
2. In the SampleJVM.cpp program, LoadLibrary() function loads jvm.dll. Please replace the path with local installation path.
3. -Djava.class.path is set to C:\\temp where TestEnvironmentVariables.class file is kept. Please replace C:\\temp with local disk path where TestEnvironmentVariables.class is kept.
4. Compile the program on cygwin command prompt using : g++ SampleJVM.cpp -o SampleJVM -I"C:\Microsoft\include\jni" -I"C:\Microsoft\include\jni\win32"
Ensure that C:\Microsoft\include\jni and C:\Microsoft\include\jni\win32 are replaced with location of jni.h and jni_md.h file. These files will be present in jdk installation.
5. Execute the program ./SampleJVM on cygwin prompt

Results :
PATH, SYSTEMDRIVE, SYSTEMROOT, WINDIR variables are getting printed.

Problem :
On windows machine, there are many environment variables already set. But they are not getting printed as output of java program.
For example APPDATA variable value is coming null hence not printed on the command prompt.
Same program if built using another compiler (e.g. visual studio) and executed on command prompt then it prints all the environment values.

As a summary, when a C program spawns a JVM and calls java method, then inside java method, we are not able to retrieve environment variable values.
This issue is occurring only when we use Cygwin build and Cygwin command prompt.

I did not find related information on this problem on Cygwin faqs link. It looks like a generic bug with Cygwin build.

Please confirm if you are able to run the sample program and reproduce the issue.
Thanks to update me on its status.


Problem reports:
Unsubscribe info:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]