Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 463138 - I'd like to have environment variable substitution for launcher.ini and command line arguments
Summary: I'd like to have environment variable substitution for launcher.ini and comma...
Status: CLOSED WONTFIX
Alias: None
Product: Equinox
Classification: Eclipse Project
Component: Launcher (show other bugs)
Version: 3.8.2 Juno   Edit
Hardware: Other All
: P3 major with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: platform-runtime-inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2015-03-25 17:26 EDT by Al Bundy CLA
Modified: 2019-09-19 14:32 EDT (History)
2 users (show)

See Also:


Attachments
Patch for R3_8_maintenance (1.13 KB, patch)
2015-03-30 06:31 EDT, Al Bundy CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Al Bundy CLA 2015-03-25 17:26:24 EDT
Currently we are using the arguments
-data
@user.home/myapp
-configuration
@user.home/myapp/configuration

in our launcher file or as launcher argument (when using webstart). 

For windows-systems I'd like to specify
-data
$APPDATA$/myapp
-configuration
$APPDATA$/myapp/configuration

because this the default location on windows systems and is most cases on the local drive where @user.home can point to a limited network share. 

I've already tried the arguments above but the result was a new folder $APPDATA$ in my application folder. :-)
Comment 1 Al Bundy CLA 2015-03-30 05:17:45 EDT
The arguments in the launcher-files
org.eclipse.equinox.launcher.Main
org.eclipse.equinox.launcher.WebStartMain
should be patched with something like this:

<pre>
  private static String[] substituteVars(String[] args)
  {
    if (args == null)
      return args;
    String[] patched = new String[args.length];
    for (int i = 0; i < args.length; i++)
      patched[i] = org.eclipse.equinox.launcher.Main.substituteVars(args[i]);
    return patched;
  }
</pre>


Because WebStartMain extends Main and both seems to call run() it's maybe enough to do
args = substituteVars(args);
at first statement.
Comment 2 Al Bundy CLA 2015-03-30 06:13:18 EDT
I've trid this locally by checking out the launcher-projects, adding this method and args = substituteVars(args); as first command in run()

	private static String[] substituteVars(String[] args) {
		if (args == null)
			return args;
		final String[] patched = new String[args.length];
		for (int i = 0; i < args.length; i++) {
			if (args[i] != null)
				patched[i] = substituteVars(args[i]);
			else
				patched[i] = null; // should never happen (theoretically)
		}
		return patched;
	}

This patch works with $APPDATA$ in launcher.ini, as command-line argument and also in jnlp as program argument.

I someone has doubts about this patch a check of a system-property (e.g. org.eclipse.equinox.launcher.enable_variable_substition could be added to the code)
Comment 3 Al Bundy CLA 2015-03-30 06:31:27 EDT
Created attachment 251986 [details]
Patch for R3_8_maintenance

I've tried the patch in R3_8_maintenance-branch because this is the version we use.
Comment 4 Al Bundy CLA 2015-03-30 18:32:40 EDT
I've set the importance to major because our app (also eclipse) becomes slow if @user.home points to a network drive. 

With the patch we want to replace @user.home with $APPDATA$ on windows systems to ensure a faster startup (btw. APPDATA is the prefered folder on windows-systems for application specific files)
Comment 5 Henno Vermeulen CLA 2015-07-20 09:05:49 EDT
Possible duplicate of bug 349834

Sorry for the late reply. We've run into the same issue and worked around it by making our own web start launcher that sets Java's user.home system variable to Windows' LOCALAPPDATA environment variable:

	private static void workaroundJavaBug6519127() {
		String userProfile = System.getenv("LOCALAPPDATA");
		if (userProfile != null) {
			System.setProperty("user.home", userProfile);
		}
	}

You will also have to work around Bug 349834 by doing something like

private static void workaroundEclipseBug349834() {
		String key = "osgi.install.area";
		String installArea = System.getProperty(key);
		if (installArea != null) {
			System.setProperty(
					key,
					installArea.replace("@user.home",
							System.getProperty("user.home")));
		}
	}
Comment 6 Al Bundy CLA 2015-07-20 12:35:43 EDT
Thanks for your reply. 

I think patching the launcher would work but unfortunately only for webstart. 

With my submitted patch it works for the default client and webstart too and gives users and administrators the abillity to configure the directories.
Comment 7 Al Bundy CLA 2016-02-15 16:52:47 EST
Am I really the only one who needs this feature?
Comment 8 Eclipse Genie CLA 2019-09-19 14:32:43 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.