Java | Maven | Environment Path Setup for macOS Catalina or Higher.
This is going to be very short and precise article on how to setup you macbook pro with java and maven.
Now macbook is coming default with zsh shell.
Steps for Java setup:
— — — — — — — — — — — — — — — — — — — — — — — — —
If you are using nano editor:(Basics of nano editor)
- nano ~/.zshenv -> It will open the file in nano editor.
- Add the content.
- Use key combination Ctrl + 0 to save and then press enter.
- Use key combination Ctrl + x to exit.
— — — — — — — — — — — — — — — — — — — — — — — — —
Java Environment Variable Path Set:
Download the java and install it and after than setup the path variable:
- nano ~/.zshenv
- Add the content : export JAVA_HOME=$(/usr/libexec/java_home) & save the file. OR we can use visual code editor for the same : code ~/.zshenv
- source ~/.zshenv
- echo $JAVA_HOME and it will print the java path :
/Library/Java/JavaVirtualMachines/jdk1.8.0_291.jdk/Contents/Home.
- java -verison will print
java version “1.8.0_291”
Java(TM) SE Runtime Environment (build 1.8.0_291-b10)
Java HotSpot(TM) 64-Bit Server VM (build 25.291-b10, mixed mode)
Maven Environment Variable Path Set:
- Download the maven from https://maven.apache.org/download.cgi
- It will download the file in downloads folder. Extract it (double click)and move the extracted file to Applications folder.(mv apache-maven-3.8.1 /Applications)
Open Terminal:
3. nano ~/.zshenv
4. Add the following lines in the file.
export M2_HOME=/Applications/apache-maven-3.8.1
export PATH=$PATH:$M2_HOME/bin
5. source ~/.zshenv.
6. echo $M2_HOME it will print the path.
/Applications/apache-maven-3.8.1
7. mvn -version will print :
Apache Maven 3.8.1 (05c21c65bdfed0f71a2f2ada8b84da59348c4c5d)
Maven home: /Applications/apache-maven-3.8.1
Java version: 1.8.0_291, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/jdk1.8.0_291.jdk/Contents/Home/jre
Default locale: en_IN, platform encoding: UTF-8
OS name: “mac os x”, version: “10.15.7”, arch: “x86_64”, family: “mac”
It you have done everything right the messages will print on your screen.
Thank you for reading!