Showing posts with label macOS. Show all posts
Showing posts with label macOS. Show all posts

Tuesday, May 26, 2020

How to change a default Java version in macOS X

Let me check the current Java version
$ java -version
java version "13.0.2" 2020-01-14
Java(TM) SE Runtime Environment (build 13.0.2+8)

In macOS Java is installed as part of /Library/Java/JavaVirtualMachines folder.

Let me go there.
$ cd /Library/Java/JavaVirtualMachines/

I want to set Java 11 as the default Java version. Let me check what all I've installed in my system.
$ pwd
/Library/Java/JavaVirtualMachines 

$ ls
jdk-11.0.7.jdk jdk-13.0.2.jdk jdk1.8.0_201.jdk

Let me set the default Java version to jdk-11.0.7.jdk
$ export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-11.0.7.jdk/Contents/Home/
$ export PATH=$JAVA_HOME/bin:$PATH

The above changes are applicable only for the current shell. To change permanently for all the shells you need set those two lines in the .bash_profile

First, go to the user home directory to run the below command
$ cd ~

$ pwd
/Users/kondal

$vim .bash_profile

Append the above two lines in the .bash_profile at the end, and save and exit.

All set.

Check again!

$ java --version
java 11.0.7 2020-04-14 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.7+8-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.7+8-LTS, mixed mode)

Good to go!!

Monday, December 16, 2019

Uninstall Python from macOS

Remove the Python 3.8 applications directory
$ sudo rm -rf "/Applications/Python 3.8”

Remove the third-party Python 3.8 framework
$ sudo rm -rf /Library/Frameworks/Python.framework/Versions/3.8

Remove the symbolic links, in /usr/local/bin, that point to this Python version. See them using
$ ls -l /usr/local/bin | grep '../Library/Frameworks/Python.framework/Versions/3.8’

and then run the following command to remove all the links:
$ cd /usr/local/bin/
$ ls -l /usr/local/bin | grep '../Library/Frameworks/Python.framework/Versions/3.8’ | awk '{print $9}' | tr -d @ | xargs rm

Edit your shell profile file(s) to remove /Library/Frameworks/Python.framework/Versions/3.8 to your PATH environment file. Depending on which shell you use, any of the following files may have been modified: ~/.bash_login, ~/.bash_profile, ~/.cshrc, ~/.profile, ~/.tcshrc, and/or ~/.zprofile.

$vim ~/.bash_profile

Resources: