Setting environment variable using JNI call

I have function declaration in Java and same function definition written in C programming language.. A JNI call from Java is made to a fuction...Function would set the environment variable { putenv(cEnvString1);} using C-built -in function ..and later return the encrypted string...

putenv is used to set the environment variable in C...Is there any alternate function to set the environment variable..? Looks like putenv is working here.
getenv function works well..

C function definition for a JNI call:-
-----------------------------------------
JNIEXPORT jstring JNICALL Java_gdm_schema_main_encryption_encryptStr
(JNIEnv *j_env, jobject j_obj)
{
char *cConnString = NULL ;

char *cEnvUserPasswd = NULL;

char cEnvString1[200]= {"FND_HIDDEN_USERPASS="};

/**
** If environment variable is not set
*/
/

if (cEnvUserPasswd == NULL)
{
fprintf(stderr,"\nError in finding connect string info. exiting ...Shafi\n");
exit(-1);
}
*/

/**
** If Environment variable contains unencrypted login-password
** i.e. called directly from bin, return it .
*/
/

if (strchr(cEnvUserPasswd , (int)'/') != NULL)
return convertToJavaString( j_env, cEnvUserPasswd ,strlen(cEnvUserPasswd));
else
{
cConnString = process_string ("INSTALL/install@fnd9i", "0", ENCRYPT);
return convertToJavaString( j_env, cConnString , strlen(cConnString));
}
*/
fprintf(stderr,"\nEncryption block.... ...\n");
cConnString = process_string ("INSTALL/install@fnd9i", "0", ENCRYPT);

putenv\("FND\_HIDDEN_USERPASS=NONE"\);
/* Prepare string for putenv function 
sprintf\(cEnvUserPasswd,"%s",cConnString\);
*/
strcat\(cEnvString1,cConnString\);


/* Keep the Connect string and position in Environment */
putenv\(cEnvString1\);


fprintf\(stderr,"\\nAfter calling encryption  %s.... ...\\n",cEnvString1\);

fprintf\(stderr,"\\nAfter calling encryption  %s..%s..%d ...\\n",j_env,cConnString,strlen\(cConnString\)\);

return convertToJavaString\( j_env, cConnString , strlen\(cConnString\)\); 

}

------------------------

May I know what reason you are trying to set Environment variable from a Java Program ?

Normally Java programs should not be closely tied up with environment. if you want to set some values to be shared. you can use System Properties of Java

Code should be in C since function definition is written in C and declaration in Java...

There are 3 environment accessing techniques in these programs
1) C
2) JNI
3) Java
In C , you are changing the environment of the process which is launched. where as the shell, or other process is not aware of it. Even in unix, we use export command for
exporting few environment variables.
The best way is to use Java's System functionality.

Thanks ! How can we export a variable from C programme...

See the manpage of putenv().