Could I please have some assistance on finding my env file?
Now I am using zsh and installed Maven successfully. Then I add Maven into the Environment variable like this:
export M2_HOME=/usr/local/apache-maven/apache-maven-3.8.4
export M2=$M2_HOME/bin
export MAVEN_OPTS=-Xms256m -Xmx512m
export PATH=$M2:$PATH
It is successful too. Now I can run "mvn -version".
Then I checked those paths by using "printenv". They are all there. For example, the Maven is like:
PATH=/usr/local/apache-maven/apache-maven-3.8.7/
Then I tried to find where I add those Paths to. I tried the following:
/etc/environment
~/.bashrc
~/.pam_environment
~/.xprofile
~/.zshrc
However, I could not find "PATH=/usr/local/apache-maven/apache-maven-3.8.7/" in any of above.
So where could it be stored in? Where is the exact env file storing these paths?
So where could it be stored in? Where is the exact env file storing these paths?
I am trying to use Python to call a Google Cloud AI platform training API. The path to my service account key JSON file is "/Users/my_mac_username/service_account_key.json", and I added the export statement in the bash_profile file so that it looks like:
# Setting PATH for Python 3.8
# The original version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.8/bin:${PATH}"
export PATH
export GOOGLE_APPLICATION_CREDENTIALS="/Users/my_mac_username/service_account_key.json"
However, I still got the error:
google.auth.exceptions.DefaultCredentialsError: Could not automatically determine credentials.
Besides, I have google-cloud-sdk folder installed. I would like to know in which file I should set the environment variable. Thanks for your help!
Assuming your terminal shell is bash, you have your environment variable setup correctly. The new variable will not be available until you reopen the terminal or run source ~/.bash_profile in the current terminal.
If you are running zsh, add the export in your ~/.zshrc file.
To determine which shell you're currently running, use: echo $SHELL from the command line
I am new to Linux Subsystem. I am trying to use a package in miniconda. Now after installing miniconda in order for it to work you need add the path like this:
export PATH=~/miniconda/bin:$PATH
I do this and the conda works. I exit the terminal and when I come back and look at my $PATH (using echo $PATH) I see is reset and I have to do it again. What should do for it to stick?
Set and export the PATH variable in your .bashrc file
vi ~/.bashrc
I want to add to the global PATH variable for CENTOS 7. I've created a script that does the following:
PATH = /usr/dir1/bin:/usr/dir1/lib:$PATH
export $PATH
The above script has been added to the directory "/etc/profile.d" as my-script.sh. I've also changed it to execute using the following command: "chmod 755 my-script.sh"
However, when I execute the command:
echo $PATH
I don't see that my additional paths have been added to the path variable.
What I'm I doing wrong?
Thanks
I'm using Mac OSX 10.8.5 with Oracle's Java 1.7 installed in addition to the mac's 1.6.
I have my JAVA_HOME set and the JAVA_HOME/bin in the front of my path.
When I run a grails compile from the command line I can see it's choosing the Java 1.6 instead of 1.7. How do I make the grails command-line choose the JDK I want?
➤ echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/jdk1.7.0_21.jdk/Contents/Home
➤ echo $PATH
/Library/Java/JavaVirtualMachines/jdk1.7.0_21.jdk/Contents/Home/bin /usr/local/share/npm/bin /Users/kbrodhagen/bin /Users/kbrodhagen/.rvm/bin /usr/bin /bin /usr/sbin /sbin /usr/local/bin /opt/X11/bin /usr/local/git/bin
➤ set -x JAVA_OPTS "-showversion"
➤ grails compile
java version "1.6.0_51"
Java(TM) SE Runtime Environment (build 1.6.0_51-b11-457-11M4509)
Java HotSpot(TM) 64-Bit Server VM (build 20.51-b01-457, mixed mode)
Which shell are you using and exactly how did you set JAVA_HOME? Grails should respect your JAVA_HOME setting as long as it is visible to the grails command, for example in bash you must export the variable rather than just setting it, in tcsh you would use setenv rather than set.
$ export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_21.jdk/Contents/Home
You can also remove /Library/Java/JavaVirtualMachines/jdk1.7.0_21.jdk/Contents/Home/bin from your PATH as /usr/bin/java will automatically delegate to the appropriate java command for the current JAVA_HOME.
If you want to localise the Java version only to Grails the best way is to edit below file,
.gvm/bin/gvm-init.sh
You can set the JAVA_HOME in this file as below,
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home
I have Java 8 in my machine and here I am setting java 1.7 for grails ONLY.
For the new SDKman method you can export JAVA_HOME in [YOUR HOME]/.sdkman/candidates/grails/[concrete version or current]/bin/grails
I needed to be able to switch between a Java 7/Grails 2.4.4 project and a Java 8/Spring 4 project in Ubuntu 12.04 and certain things made this difficult:
I'd set Java 8 as the default version after installing it using sudo apt-get install oracle-java8-set-default, but that apparently creates /etc/profile.d/jdk.sh and /etc/profile.d/jdk.csh containing JAVA_HOME, JRE_HOME and other env vars that prevented me from swapping the JDK.
This kinda worked, but the above env vars clouded things too much.
In the end, I removed both of the above items from my environment and the files in /etc/profile.d and I now:
Change the JDK by running sudo update-java-alternatives -s java-8-oracle (or java-7-oracle) as mentioned in the webupd8 article;
Run gvm to set the current or default grails and other tools as required
Seems messier than it should be, but I think it is working now.
If you use SDKMAN to install Grails (which is the currently recommended method), you can add any versions of Java you have installed to SDKMAN and it will manage them for you as well. For example:
sdk install java openjdk-8 /usr/lib/jvm/java-8-openjdk-amd64
sdk use java openjdk-8
Note that this will set JAVA_HOME for your user, so if you don't want that you may want to consider one of the other options.
$ echo $JAVA_HOME
/home/user/.sdkman/candidates/java/current
For more information: SDKMAN local versions