Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Plugin Development Environment (PDE) » How to set a Windows System Environment Variable for a plug-in
How to set a Windows System Environment Variable for a plug-in [message #665052] Wed, 13 April 2011 06:50 Go to next message
PW-toXic is currently offline PW-toXicFriend
Messages: 3
Registered: April 2011
Junior Member
Hi,

Im not sure if this is the proper forum for my question, but I'll give it a try:

I'm currently working on an Eclipse plug-in which tries to use the CAD Framework OpenCascade ( http://www.opencascade.org/ ) to display different machines. Since OpenCascade is a framework / library written in C++, JNI is required. There is a project calle JCAE, which uses SWIG to semi-auto generated those JNI ( http://jcae.sourceforge.net/ ).
As written on the project page of JCAE, I have to set the system environment variable MMGT_OPT = 0;

I have no clue how i could do this for my plug-in. For development, I can set this variable with the "run configurations" in the environement tab. But I need a solution, where I can set this environment variable relative to the plug-in and not relative to my Eclipse Installation. So everybode who checks out my plug-in via SVN does not have to set a run configuration manually.

Any Ideas?

System.setProperty("MMGT_OPT", "0"); doesnt seem to work.
Re: How to set a Windows System Environment Variable for a plug-in [message #665129 is a reply to message #665052] Wed, 13 April 2011 10:59 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

It would be System.setenv(*) if that worked (Java 5 or 6) ... but if the
system has already tried to load the libraries, the option might not be
exposed to the native libraries (i.e. a timing problem).

The only reliable way to set environment variables is to set them before
launching.

PW


--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Platform_Expression_Framework
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/helios/index.jsp?topic=/org.eclipse. platform.doc.isv/guide/workbench.htm


Re: How to set a Windows System Environment Variable for a plug-in [message #665228 is a reply to message #665129] Wed, 13 April 2011 19:19 Go to previous messageGo to next message
PW-toXic is currently offline PW-toXicFriend
Messages: 3
Registered: April 2011
Junior Member
there is no function called setenv.. only getenv() is available...
And the comment on getenv explicitly says that changing the entries of the map does not change the system variables!

I'd like to set a system variable before start, but i dont know how i can do this.. is there a command line argument which does this? this would help maybe
-Dfoo=bar does not set environment variables but properties, which im not looking for
Re: How to set a Windows System Environment Variable for a plug-in [message #665347 is a reply to message #665228] Thu, 14 April 2011 12:07 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

On 04/13/2011 03:19 PM, PW-toXic wrote:
> I'd like to set a system variable before start, but i dont know how i
> can do this.. is there a command line argument which does this? this
> would help maybe
> -Dfoo=bar does not set environment variables but properties, which im
> not looking for

It's the launching environment that sets those variables, the JVM
process itself doesn't.

i.e. you have to do something like:

export FOO=bar
eclipse <other args>

or

set FOO=bar
eclipse.exe <other args>

PW

--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Platform_Expression_Framework
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/helios/index.jsp?topic=/org.eclipse. platform.doc.isv/guide/workbench.htm


Re: How to set a Windows System Environment Variable for a plug-in [message #665372 is a reply to message #665052] Thu, 14 April 2011 13:19 Go to previous messageGo to next message
PW-toXic is currently offline PW-toXicFriend
Messages: 3
Registered: April 2011
Junior Member
When i open the file client.product of our deployment plug-in there is a tab called "Launching"
The only textfields there are called "Program Argments" and "VM arguments". So I dont think "SET foo=bar" will help me...
Where do you think i should add this code?
Re: How to set a Windows System Environment Variable for a plug-in [message #665405 is a reply to message #665372] Thu, 14 April 2011 14:02 Go to previous message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

On 04/14/2011 09:19 AM, PW-toXic wrote:
> When i open the file client.product of our deployment plug-in there is a
> tab called "Launching"
> The only textfields there are called "Program Argments" and "VM
> arguments". So I dont think "SET foo=bar" will help me...
> Where do you think i should add this code?

It won't. AFAIK you either have to set the variable as part of the OS,
or use a script to launch the entire eclipse so you can set the variable
before launching.

Within eclipse, you specify that on the launch config Environment tab,
so that eclipse can set the envvar for the child process.

PW

--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Platform_Expression_Framework
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/helios/index.jsp?topic=/org.eclipse. platform.doc.isv/guide/workbench.htm


Previous Topic:init() method in Wizard not getting called
Next Topic:Create and set a target platform programatically
Goto Forum:
  


Current Time: Sat Aug 08 15:58:13 GMT 2020

Powered by FUDForum. Page generated in 0.01502 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top