15

With eclipse, I know how to use variables in my launch configurations. I also know there exist a set of predefined variables such as ECLIPSE_HOME or WORKSPACE_LOC.

What I don't know is the extensive list of these predefined variables (ie : variables names and values). Is there such a resource ?

merours
  • 4,076
  • 7
  • 37
  • 69

4 Answers4

16

I found a very good example about path variables in eclipse help documentation:

workbench user guide-concepts-ant & external tools

Lets assume your Eclipse workspace directory is: c:\eclipse\workspace and you have two projects, MyProject1 and MyProject2. The first project, MyProject1, is located inside the workspace directory, the second project, MyProject2, is located outside the workspace directory at c:\projects\MyProject2. Lets look at how the variable examples below will be expanded when an external tool is run, if the resource /MyProject2/MyFolder/MyFile.txt is selected.

    ****Variable Example ~~> Expanded Results****

    ${workspace_loc} ~~> c:\eclipse\workspace
    ${workspace_loc:/MyProject1/MyFile.txt} ~~> c:\eclipse\workspace\MyProject\MyFile.txt
    ${workspace_loc:/MyProject2/MyFile.txt} ~~> c:\projects\MyProject2\MyFile.txt
    ${project_loc} ~~> c:\projects\MyProject2
    ${project_loc:/MyProject1/MyFile.txt} ~~> c:\eclipse\workspace\MyProject
    ${container_loc} ~~> c:\projects\MyProject2\MyFolder
    ${resource_loc} ~~> c:\projects\MyProject2\MyFile.txt
    ${project_path} ~~> /MyProject2
    ${container_path} ~~> /MyProject2/MyFolder
    ${resource_path} ~~> /MyProject2/MyFolder/MyFile.txt
    ${project_name} ~~> MyProject2
    ${container_name} ~~> MyFolder
    ${resource_name} ~~> MyFile.txt
    ${build_type} ~~> none
Mohammad Kholghi
  • 533
  • 2
  • 7
  • 21
Wei
  • 351
  • 3
  • 5
  • This answer comes from [this](https://help.eclipse.org/latest/index.jsp?topic=%2Forg.eclipse.platform.doc.user%2Fconcepts%2Fconcepts-exttools.htm) place in thhe official docs. It's also more elaborate on this topic. I still don't know how they expand `${project_loc:/MyProject1/MyFile.txt}` into `c:\eclipse\workspace\MyProject` though. The other issue is I've seen project name written like this: `${ProjName}`, but those can be re-defined so maybe that's the case. – z33k Apr 06 '23 at 11:28
4

If you mean variables specified in things like the 'Location' field in the launch configuration then clicking the 'Variables...' button next to the field shows you a complete list of the currently defined variables.

Since plugins can add new variables to this list it isn't really possible to give a definitive list as it depends on which plugins you have installed.

greg-449
  • 109,219
  • 232
  • 102
  • 145
  • I'm really just looking for existing variables with a fresh eclipse installation (some of them are evoqued in [this page](http://help.eclipse.org/luna/index.jsp?topic=%2Forg.eclipse.platform.doc.user%2Fconcepts%2Fcpathvars.htm), for instance) – merours May 21 '15 at 12:08
  • That is a different set of variables again - you must be very specific about what you are asking about. That page is for linked resources, only the four variables mentioned on the help page are available in that case. – greg-449 May 21 '15 at 12:12
  • Trouble is, I am not looking specifically for a variable, I'd just like to know which already exist (so that I don't create duplicate non standart variable). On top of that, I sometimes use variables without knowing their values, something that bugs me. – merours May 21 '15 at 12:22
  • The variables are different for each different case so I can't give you an answer that applies to everything. – greg-449 May 21 '15 at 13:08
1

Open the preferences and search for "Classpath Variables".

Aaron Digulla
  • 321,842
  • 108
  • 597
  • 820
1

${workspace_loc}

and

${ProjDirPath}

worked for me in Eclipse Oxygen.

4b0
  • 21,981
  • 30
  • 95
  • 142
Daniel
  • 11
  • 1
  • What type of variables are these ${workspace_loc} ? For example where does this syntax come from and what does the $ indicate? – fractal80y Jul 28 '21 at 05:13