cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
james_decosta
Level 9

hi well i am using a custom code action for refreshing the environment variable

hi,
i am using a custom code action for refreshing the environment after setting system environment variables but i don t know whether its working or not as i am unable to understand if the environment variables are refreshed.
I am using the sample jar file given in the SAMPLE CODE AND am i supposed t o add any dependancy for it .
The sample jar file is attached herein\
Labels (1)
0 Kudos
(10) Replies
james_decosta
Level 9

hi,
i am adding the file in the execute custom code action and i give the full name of the class attached herein but i did not attach any dependency .
Am i right in my action as i get refreshing environment message while installing and also in the install log execute custom code : refresh environment variable
success.
Can i use the system environment variables after setting the environment variables in the installer and adding this custom code action after that without restarting the system.
I just wanted to double check this action,am i right in this approach.
Regards,
james.
0 Kudos
james_decosta
Level 9

hi,
well can anyone guide me in verifying if the system environment variables are refreshed through the code as i need to restart the system after setting the environment variables.
I do not want to restart the system and start using the environment variables in my next actions.
Regards,
james
0 Kudos
james_decosta
Level 9

hi,
i have set the system environment variable say XXX_HOME using installanywhere variable and i use this XXX_HOME and i use it in my post installation tasks.
But i am unable to refresh the system environment variable as i get null in place of XXX_HOME,what shall i do??????????????????????????????
james.
0 Kudos
purcellk24
Level 7

Wasn't this answered in this other post? http://community.macrovision.com/showthread.php?t=177538
0 Kudos
james_decosta
Level 9

hi,
this is actually a problem i face in the custom code for refreshing the system environment variables using the custom code given to me by installanywhere.
I have followed the instructions liike :

Showing the jar file path.
And then i gave the class name of the class.
It was putting some refresh.dll file in the win32 and then calling it for refresh but i am afraid it is not refreshing the system environment variable.
james.
0 Kudos
purcellk24
Level 7

So then,
The best way for anyone to help is to post a sample project, not the custom code from IA. And explain what the end result should be and what you get instead.

Another idea,
If you have the variable already from another step, why not just use that in your post installation instead from the "system environment"
0 Kudos
james_decosta
Level 9

hi,
please extract and change the file from install.asl to install.exe and execute
and please check for SAMPLESTDOUT.log in 😧 drive.

The sample custom code i have written is as follows:
---------------------------------------------------------------------------------------
package com.sample.source;

import com.zerog.ia.api.pub.CustomCodeAction;
import com.zerog.ia.api.pub.InstallException;
import com.zerog.ia.api.pub.InstallerProxy;
import com.zerog.ia.api.pub.UninstallerProxy;

public class SampleCustomCode extends CustomCodeAction {

@Override
public String getInstallStatusMessage() {
// TODO Auto-generated method stub
return null;
}

@Override
public String getUninstallStatusMessage() {
// TODO Auto-generated method stub
return null;
}

@Override
public void install(InstallerProxy ip) throws InstallException {
String FilePath = System.getenv("JAMES_HOME");
String java_home=System.getenv("JAVA_HOME");
String yyy_home=System.getenv("YYY_HOME");
System.out.println("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"+FilePath);
System.out.println("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"+java_home);
System.out.println("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"+yyy_home);
String anotherPathtoDisplay=FilePath+"\\DUMMY FOLDER\\DUMMYFILETOBEUSED.txt";
System.out.println("gggggggggggggggggggggggggggggggggggggggg"+anotherPathtoDisplay);

}

@Override
public void uninstall(UninstallerProxy arg0) throws InstallException {
// TODO Auto-generated method stub

}

}
-----------------------------------------------------------------------------------------------------------
WHAT I expect in the D:\SAMPLESTDOUT.log is
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"+FilePath
"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"+java_home
"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"+yyy_home




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

BUT THIS IS WHAT I GOT IN THE SAMPLESTDOUT.log


FileEncoding::initialize()- platform default encoding: Cp1252
FileEncoding::initialize()- using encoding: Cp1252
ExtractToFile: target = C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\I1203523926\Windows\refresh.dll
ExtractToFile: extractWhatURL = jar:file:/C:/Documents%20and%20Settings/Administrator/Local%20Settings/Temp/I1203523926/InstallerData/Execute.zip!/refresh.dll
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXnull
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXC:\Program Files\Java\jdk1.5.0_08
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXnull
ggggggggggggggggggggggggggggggggggggggggnull\DUMMY FOLDER\DUMMYFILETOBEUSED.txt
0 Kudos
purcellk24
Level 7

I've answered the question here -> http://community.macrovision.com/showthread.php?t=177470

When you are making a System.getenv() call, you are getting settings for the current Virtual Machine. Just because you changed the "environment" at the system level, doesn't mean the currently running JVM environment has been updated. Just like if you opened a cmd window. That window has a particular environment. That environment doesn't get automatically updated because you changed it at the "system" level. It only gets updated when you explicitly set it or you open a new cmd window.

There are 2 ways aound this.
1. Use a System.setProperty(key, value) call.
or 2. You said that in IA, you were setting the variable. Why not just use that variable?
Edit/Delete Message
0 Kudos
james_decosta
Level 9

hi,
my problem is like when i set the JAVA_HOME to $USER_INSTALL_DIR$$/$jdk
And i append $USER_INSTALL_DIR$$/$jdk$/$bin to the environment variable PATH
After doing this,i start the application server jboss after post installation
wherein i need JAVA_HOME but i get

JAVA_HOME:

JBOSS_HOME:(THIS WILL BE getting $USER_INSTALL_DIR$$/$jboss-4.2.0.GA)

and then i get this message:

java is not set press any key to continue...................
and when i press it the jboss server window vanishes.
So i need to refresh the JAVA_HOME after setting it.

In the post install, i execute a batch script

:
call $USER_INSTALL_DIR$$/$jboss$/$bin$/$run.bat


Again in more ----------------------------------------------------------------------------------------------------

Again in one more installer i put a properties file in JAMES_HOME (say XXX.properties file in JAMES_HOME\XXX FOLDER.)

So when i set the environment variable JAMES_HOME,after that i start eclipse in post install task and my application tries to read from the system environment variable JAMES_HOME and it is unable to get it and it is unable to start up.
My problems will be solved if the refreshenvironment class starts working.
MY environment is WINDOWS XP.


JAMES_HOME\XXX FOLDER\XXX.properties

I can see that it is extracting refresh.dll file but it is not refreshing.Thats why i got the output in the SAMPLESTDOUT.log as given below:

null\xxxconfig.properties.
And so on any suggestions are awaited,
atleast if it able to refresh JAVA_HOME after setting it then i will able to start jboss .
james.
aNY SUGGESTIONS ARE AWAITED
0 Kudos
james_decosta
Level 9

hi,
i am unable to achieve this feature even now any suggestions are awaited.
I need the refreshed system environment variables for my application.
Is this possible,can anyone say if it possbile through the custom code provided which contains a refresh.dll file or is it not possible due to improper functioning of custom code.
It happens on windows xp platform
Is this possible
0 Kudos