Uncategorized

Installing and Managing JAVA on MAC OS


To install different version of JAVA on mac is tedious work .Today post ,I will explain how to install Java on Mac using HomeBrew.

Install HomeBrew

Homebrew is a free and open-source software package management system that simplifies the installation of software on Apple’s macOS operating system and Linux. We will use this homebrew to install a different version of Java and maintain all of them with a single command.

Homebrew installation page https://brew.sh/

Install cask – brew install cask

Cask for Java

brew cask is an extension to brew that allows management of java and other applications.

To install the latest Java on mac ,

brew cask install java - latest

To install the Java 8 on mac

brew cask install adoptopenjdk/openjdk/adoptopenjdk8 -Java 8

To install the Java 9 on mac

brew cask install adoptopenjdk/openjdk/adoptopenjdk9

You can see the installed the Java at below locations ,

cd /Library/Java/JavaVirtualMachines/

OutOfMemory Error in Java
To avoid Memory related error in Java while spawning multiple thread .

export JAVA_OPTS="-XX:+UseG1GC -Xmx2048m -Xms2048m 
-DIGNITE_NO_SHUTDOWN_HOOK=true 
-DIGNITE_PERFORMANCE_SUGGESTIONS_DISABLED=true 
-XX:+HeapDumpOnOutOfMemoryError 
-XX:HeapDumpPath=/Users/<username>/JAVAMEM/heapDump.hprof"

Set the desired Java library on your editor and start your work happily…! 🙂




Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.