Over a million developers have joined DZone.

Eclipse Build Variables

DZone's Guide to

Eclipse Build Variables

· DevOps Zone ·
Free Resource

Is the concept of adopting a continuous everything model a daunting task for your fast moving business? Read this whitepaper to break down and understand one of the key pillars of this model in Continuous Governance: The Guardrails for Continuous Everything.

This post is not about variables in my application code (which I debug). It is about using Variables in Eclipse for building projects. Eclipse variables allow me to make my projects ‘position independent’ whenever I cannot use a path relative to my projects or workspace.

Eclipse Variables

Which variables are used where in Eclipse might be sometimes not very clear. Depending in which context variables are used, not everything might be available. This link for example gives a list of variables which can be used to invoke an external tool.

Build Variables

Eclipse comes with many built-in variables, especially for the build system. If I want to see what variables are already defined, I can show them in the project properties, under C/C++ Build > Build Variables with enabled option ‘Show system variables’:

System Build Variables

System Build Variables

With the ‘Add…’ button I can define and add my own variables, available for that project:

Define a new build variable

Define a new build variable

If above operation is done on a project, then the setting is for the project only. If I want to add a variable for the workspace, I can do this using the menu Window > Preferences:

Workspace Build Variables

Workspace Build Variables

Global System Variables

Eclipse automatically includes the system (e.g. Windows) environment variables. Many dialogs have the ‘Variables…’ button where I can use my variables, including the variables defined on system level:

System Variables

System Variables

System variables: one way or the other

So if I want to have a variable for every workspace, one way is to define it at the system level. However, this is not a good way as this clutter the variables for every application.

Batch File

A solution to this to create my custom batch file where I define my variables, and at the end of this batch file I launch Eclipse. That way the extra variables are only for this Eclipse session.

cwide-env File

Another very nice way CodeWarrior Eclipse offers is using the cwide-env file located in the eclipse sub-folder of the installation:

cwide-env File

cwide-env File

I can define variables here, or extend existing ones:

  • -add: add string to the variable at the end
  • -prepend: add string to the variable at the beginning

That way I can easily manipulate existing system variables or create new ones which then are used by Eclipse.


Variables in Eclipse help me to define paths to source files and folders outside of a project or workspace. With variables I avoid using absolute paths which would make porting projects from one machine to another difficult. I can define variables for projects, for the workspace or use system variables. With CodeWarrior I have a cwide-env file which is used to extend the system variables.

Happy Variabling :-)

Are you looking for greater insight into your software development value stream? Check out this whitepaper: DevOps Performance: The Importance of Measuring Throughput and Stability to see how CloudBees DevOptics can give you the visibility to improve your continuous delivery process.


Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}