Mac Os X Set Environment Variable For Application

broken image


UNIX, Linux, Mac OS X: You can set environment variables at the command line, in an environment configuration file, or in a login file. Windows: You can set environment variables in the system applet or at the command line. On Mac OS X, you must set the DYLDLIBRARYPATH environment variable before you try to execute one of these applications so the runtime linker can find the Maya shared libraries. The recommended procedure for preparing to build and run stand-alone applications is to set the following environment variables. HowTo: Set an Environment Variable in Mac OS X - Terminal Only The process of setting environment variables in the Terminal will be familiar to those with experience with Linux or UNIX. It involves editing files in /etc for global environment variables, and in your home directory for user specific environment variables. Apple / Bash / Command Line Tools / MAC OS / Tools; 0. How to set environment variable in windows 10? Unable to connect to windows store app. Access is denied. The above mentioned commands will set the JAVAHOME environment variable for a single user. What if you want that this variable should be set globally for all the users who will be using the machine? The answer to this question is the file /etc/profile.

Question or issue on macOS:

Many Java applications that use shell scripts to configure their environment use the JAVA_HOME environment variable to start the correct version of Java, locate JRE JARs, and so on.

In macOS X 10.6, the following paths seem to be valid for this variable

Some of these are symlinks to the actual current VM (as defined in the Java Preference pane).

But which one should be used—or is it okay to use any of them?

How to solve this problem?

Solution no. 1:

I just set JAVA_HOME to the output of that command, which should give you the Java path specified in your Java preferences. Here's a snippet from my .bashrc file, which sets this variable:

I haven't experienced any problems with that technique.

Occasionally I do have to change the value of JAVA_HOME to an earlier version of Java. For example, one program I'm maintaining requires 32-bit Java 5 on OS X, so when using that program, I set JAVA_HOME by running:

For those of you who don't have java_home in your path add it like this.

References:

Solution no. 2:

Also, it`s interesting to set your PATH to reflect the JDK. After adding JAVA_HOME (which can be done with the example cited by ‘mipadi'):

export JAVA_HOME=$(/usr/libexec/java_home)

Add also in ~/.profile:

export PATH=${JAVA_HOME}/bin:$PATH

P.S.: For OSX, I generally use .profile in the HOME dir instead of .bashrc

Solution no. 3:

I am having MAC OS X(Sierra) 10.12.2.

I set JAVA_HOME to work on React Native(for Android apps) by following the following steps.

  • Open Terminal (Command+R, type Terminal, Hit ENTER).

  • Add the following lines to ~/.bash_profile.

    export JAVA_HOME=$(/usr/libexec/java_home)

  • Now run the following command.

    source ~/.bash_profile

  • You can check the exact value of JAVA_HOME by typing the following command.

    echo $JAVA_HOME

The value(output) returned will be something like below.

/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home

That's it.

Solution no. 4:

I'm on Mac OS 10.6.8

The easiest solution works for me is simply put in

To test whether it works, put in

it shows

Set
Mac
Mac os add environment variable

Mac Os X Set Environment Variable For Applications

you can also test

Mac Os Add Environment Variable

Solution no. 5:

Nowadays Java seems to be installed in /Library/Java/JavaVirtualMachines

Solution no. 6:

I tend to use /Library/Java/Home. The way the preferences pane works this should be up to date with your preferred version.

Solution no. 7:

That above works not any more in YOSEMITE for GRAPHICAL APPLICATIONS! Like eclipse, or anything started with Spotlight. (.bash_profile, launchd.conf works for terminal sessions only.)
Before starting eclipse, just open a terminal window, and give out the following command:

(With your installation path! Perhaps works with $(/usr/libexec/java_home) instead of the full path too.)

View the whole excellent article about the permanent solution here:
Setting environment variables via launchd.conf no longer works in OS X Yosemite/El Capitan/macOS Sierra?

Solution no. 8:

I've found this stack to help, i was having the same issue and i could fix:

Bundled mac os x application

My java path was here:

/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home

and was needed to put into my .bash_profile:

Environment

Mac Os X Set Environment Variable For Applications

you can also test

Mac Os Add Environment Variable

Solution no. 5:

Nowadays Java seems to be installed in /Library/Java/JavaVirtualMachines

Solution no. 6:

I tend to use /Library/Java/Home. The way the preferences pane works this should be up to date with your preferred version.

Solution no. 7:

That above works not any more in YOSEMITE for GRAPHICAL APPLICATIONS! Like eclipse, or anything started with Spotlight. (.bash_profile, launchd.conf works for terminal sessions only.)
Before starting eclipse, just open a terminal window, and give out the following command:

(With your installation path! Perhaps works with $(/usr/libexec/java_home) instead of the full path too.)

View the whole excellent article about the permanent solution here:
Setting environment variables via launchd.conf no longer works in OS X Yosemite/El Capitan/macOS Sierra?

Solution no. 8:

I've found this stack to help, i was having the same issue and i could fix:

My java path was here:

/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home

and was needed to put into my .bash_profile:

export JAVA_HOME='/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home'

Hope help

Solution no. 9:

For me maven seems to work off the .mavenrc file:

I'm sure I picked it up on SO too, just can't remember where.

Solution no. 10:

Create file ~/.mavenrc

then paste this into the file

export JAVA_HOME=$(/usr/libexec/java_home)

test

mvn -v

Hope this helps!





broken image