Launch mac eclipse with environment variables set

后端 未结 8 1534
隐瞒了意图╮
隐瞒了意图╮ 2020-11-29 00:16

My company provides an eclipse based development environment which needs some environment variables setting up for the underlying toolchain so multiple versions can be insta

相关标签:
8条回答
  • 2020-11-29 00:19

    I created the following:

    alias start-eclipse='open /Applications/eclipse/Eclipse.app'

    If you run start-eclipse from the command line, all env vars will be picked up. This way, you only need to maintain a single set of env vars across both command-line and eclipse environments.

    0 讨论(0)
  • 2020-11-29 00:25

    Link to Eclipse doesn't use the path set in .bashrc

    1. Create simple script
    #!/bin/bash
    source /home/user/.environment_variables
    /home/user/eclipse_cpp/eclipse -Duser.name="My Name"
    

    2. Next put your all system variables in file /home/user/.environment_variables (any file you want)

    My looks like:

    export COCOS_ROOT=/home/user/Projects/edukoala
    export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64/
    

    3. Now you can delete your variables in .bashrc and put line

    source /home/user/.environment_variables
    

    Everything works fine :)

    0 讨论(0)
  • 2020-11-29 00:29

    None of the above worked for me. you have to set Eclipse -> Preferences -> Terminal -> Arguments set to --login That will instruct Eclipse to login with your account just after opening Terminal.

    See screenshot:

    Reference: https://marketplace.eclipse.org/comment/4259#comment-4259

    0 讨论(0)
  • 2020-11-29 00:30

    Take a look at a related question: Environment variables in Mac OS X.

    Basically, this involves the creation of a ~/.MacOSX/environment.plist file.

    Log out and Log in for the environment.plist to get picked up by .App's

    0 讨论(0)
  • 2020-11-29 00:33

    As pointed out in https://github.com/atom/atom/issues/7045, the environment variables can be loaded automatically, without explicit source ~/.bash_profile by using

    #!/usr/bin/env bash -l
    

    instead of

    #!/bin/bash
    source ~/.bash_profile
    

    after that, in both cases, follows

    exec "`dirname \"$0\"`/eclipse" $@
    

    It works great for me, thanks for all previous work.

    0 讨论(0)
  • 2020-11-29 00:34

    This worked perfectly in OS X Yosemite:

    1. Open /Applications/Automator.
    2. When the drop-down appears asking you what kind of document you want to create, choose "Application."
    3. In the second-from-the-left list, double-click "Run Shell Script."
    4. In the right side delete the "cat" that gets put there automatically, and replace it with this:

      source ~/.bash_profile && /Applications/eclipse/Eclipse.app/Contents/MacOS/eclipse
      

    Now go to File->Save, and save the application to your Applications directory. I named it "Eclipse" with a capital 'E' so as not to conflict with the "eclipse" directory I already had. For good measure, you can even give it the Eclipse icon by selecting the real eclipse app, pressing command-i, selecting the icon, pressing command-c, then selecting the automator "Eclipse" app, pressing command-i, selecting the icon, and pressing command-v.

    Now you can open the app, or even drag it to your dock. Note that if you start it, the "real" eclipse will still show up in your dock as a separate icon, but you can't have everything. :)

    0 讨论(0)
提交回复
热议问题