tags:

views:

34

answers:

2
A: 

Some of those information should be able from a Plugin through the org.eclipse.core.runtime.Platform class, as shown by the org.eclipse.debug.internal.core.SystemVariableResolver source code:

public String resolveValue(IDynamicVariable variable, String argument) throws CoreException {
    if ("ARCH".equals(argument)) { //$NON-NLS-1$ 
        return Platform.getOSArch(); 
    } else if ("ECLIPSE_HOME".equals(argument)) { //$NON-NLS-1$ 
        URL installURL = Platform.getInstallLocation().getURL(); 
        IPath ppath = new Path(installURL.getFile()).removeTrailingSeparator(); 
        return getCorrectPath(ppath.toOSString()); 
    } else if ("NL".equals(argument)) { //$NON-NLS-1$ 
        return Platform.getNL(); 
    } else if ("OS".equals(argument)) { //$NON-NLS-1$ 
        return Platform.getOS(); 
    } else if ("WS".equals(argument)) { //$NON-NLS-1$ 
        return Platform.getWS(); 
    } 
    return null;
} 

Platform.getCommandLineArgs() should complete the display for the eclipse session (not for your program though).


For a RCP program, see this thread

Using the Application start(IApplicationContext context) method:

String[] args = (String[]) context.getArguments().get(IApplicationContext.APPLICATION_ARGS);
VonC
Thanks, that does it. For some reason I thought there was something fancier than Platform.get* methods for this.
Fredrik
A: 

What you're seeing there is the session info for the Eclipse program, not yours.

Your program is run in a JVM of its own, and with far fewer arguments. The eclipse environment stuff is not really very relevant for your program.

The actual command line arguments to your program are of course available as arguments to the main() method. A few other items of potential interest will be visible in the Java properties, which you can obtain with System.getProperty(). This documentation contains the names of the "standard" properties: http://java.sun.com/j2se/1.4.2/docs/api/java/lang/System.html#getProperties%28%29

Carl Smotricz