public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Problem to retrieve environment variable values in JVM when Cygwin prompt is used
@ 2017-12-18 13:10 Toke, Mahesh
  0 siblings, 0 replies; only message in thread
From: Toke, Mahesh @ 2017-12-18 13:10 UTC (permalink / raw)
  To: cygwin; +Cc: Virulkar, Nitin, Badhei, Sankharaj

[-- Attachment #1: Type: text/plain, Size: 2286 bytes --]

Hi, 

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. TestEnvironmentVariables.java 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.

Regards,
Mahesh



[-- Attachment #2: Type: text/plain, Size: 219 bytes --]


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2017-12-18 11:35 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-18 13:10 Problem to retrieve environment variable values in JVM when Cygwin prompt is used Toke, Mahesh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).