cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
sandy_2008
Level 7

How to set PATH and CLASSPATH

I have used 'Set System Variables' for setting PATH and CLASSPATH variables.
This has two disadvantages:
1. It prepends the entries blindly, without checking if there exists the same entries or not.
2. It doesn't remove the entries on uninstallation.

Is there any other way to add PATH and CLASSPATH values?
Labels (1)
0 Kudos
(12) Replies
sandy_2008
Level 7

Does uninstaller really removes the entries the installer made in the environment variables?
0 Kudos
sandy_2008
Level 7

Have I asked some stupid question here? Please do reply.
0 Kudos
amul_mitm
Level 4

Put a rule, on whether variable lax.nl.env.PATH or lax.nl.env.exact_case.Path contains the string that you are adding to it. If this rule executes to true, then the action should not be performed, otherwise it should be.

Do same with Classpath,

Put a reverse action in (Pre/Post)Uninstallation.

Simple.
0 Kudos
sandy_2008
Level 7

How to put a reverse action in uninstallation? It means to set the variables to the original values? How to do it?
0 Kudos
sandy_2008
Level 7

During installation, I'll copy the PATH variable value to some variable and then use this variable again during un-installation to set the PATH variable to the original value.
What variable can be used bot during installation and un-installation time?Can I use USER_MAGIC_FOLDER?
0 Kudos
qqqqqq
Level 7

But if user modifies the PATH after the installation of ur install.exe .. .. then if he uninstalls .. the changes made by him will be lost !!:eek:
0 Kudos
sandy_2008
Level 7

Oh yes, that make sense..
I plan to put this logic:
1. Split the PATH value with ";" and read it one-by-one in a buffer. If it matches USER_INSTALL_DIR, don't add it to the buffer, else add it.
2. set the PATH to the buffer value.

or is there any other mechanism?
0 Kudos
pv7721
Level 20

sandy_2008 wrote:
Oh yes, that make sense..
I plan to put this logic:
1. Split the PATH value with ";" and read it one-by-one in a buffer.


Beware of the differences between platforms: while it is true that ";" is the separator on Windows, it's ":" the separator on Unices!
0 Kudos
sandy_2008
Level 7

Thanks Vlad..Here,I'm talking about Windows.
Our installation will add some entries to the CLASSPATH like,
/rt.jar;/jdo.jar;/jvi-jdk.jar
I have written a custom code which will be run in post-uninstallation and which will split the CLASSPATh value with ";" and then add to the buffer the values that doesn't contain rt.jar. That means the objective is to remove rt.jar path from CLASSPATH.
This is my code.
[CODE]
public void uninstall( UninstallerProxy ip )
{
try
{
//get the CLASSPATH value
String GetClassPath = (String) ip.getVariable("lax.nl.env.CLASSPATH");
String NewClassPath = "";
String[] NCP;
NCP = (GetClassPath).split(";");
StringBuffer buff = new StringBuffer("");
for(int i =0; i < NCP.length ; i++) {
if (!NCP.contains("rt.jar")){
buff.append(NCP);
buff.append(";");
NewClassPath = buff.toString();
}
}
NewClassPath = (String) ip.substitute (NewClassPath);
ip.setVariable("NEW_CLASSPATH", NewClassPath);
}
catch(Exception e)
{
String errorMsg = e.getMessage();
System.out.println(errorMsg);
}
[/CODE]

and then I added 'Set System Environment variable' and I set CLASSPATH to NEW_CLASSPATH..
But it doesn't seem to work.. Have I done something wrong here?
0 Kudos
sandy_2008
Level 7

In the pre_install tak, I have added the custom code to get the CLASSPATH value, and display it in message dialog, but it doesn't show any value. Why?

String GetClassPath = (String) ip.getVariable("lax.nl.env.CLASSPATH");
MessageDialog.showAndWait("Product Installation", GetClassPath, "OK");
0 Kudos
sandy_2008
Level 7

I used the following code to get the classpath value.

String GetClassPath = System.getProperty("java.class.path",".");

But the code doesn't get the values set in the system and instead contains the these values:

C:\WINDOWS\TEMP\I1227095198\InstallerData\IAClasses.zip;C:\WINDOWS\TEMP\I1227095198\InstallerData\Execute.zip;C:\WINDOWS\TEMP\I1227095198\Windows\InstallerData\Execute.zip;C:\WINDOWS\TEMP\I1227095198\InstallerData\Resource1.zip;C:\WINDOWS\TEMP\I1227095198\Windows\InstallerData\Resource1.zip;C:\WINDOWS\TEMP\I1227095198\InstallerData;C:\WINDOWS\TEMP\I1227095198\Windows\InstallerData;

Why?
0 Kudos
qqqqqq
Level 7

did you get any solution to this?
0 Kudos