Posts

Showing posts from February, 2022

n - Interactively Manage Your Node.js Versions on macOS

 n  is a Node.js version management: no sub-shells, no profile setup, no convoluted, just simple. Supported  Platforms  n  is supported on macOS, Linux, including with Windows Subsystem for Linux, and various other  unix-like systems. It is written as a BASH script but does not require you to use BASH as your command shell.  n  does not work in native shells on Microsoft Windows (like PowerShell), or Git for Windows BASH, or with the Cygwin DLL. Installation If you already have Node.js installed, an easy way to install  n  is using   npm  : sudo npm install -g n The   n  command downloads and installs to  /usr/local    by default. Installing Node.js Versions Simply execute  n  <version>  to download and install a version of Node.js. If  <version>  has already been downloaded,  n  will install from its cache. sudo n 10.16.0 sudo n 10 sudo n install 10 sudo n lts sudo n latest Execute  n  on its own to view your downloaded versions, and installed the selected version. %

How to compile and run Java programs from the Terminal on macOS?

As an aside, some people prefer to create code directly in the Terminal (rather than use an SDK). Here is how to compile and run Java from the Terminal in OS X. Open Terminal. Enter mkdir HelloWorld to create a new directory and cd HelloWorld to move into it. Enter touch HelloWorld.java to create an empty Java file. Now enter open HelloWorld.java to open and edit the file in default text editor. Or if you wish you can edit HelloWorld.java with your favourite editor ( type " open -e Helloworld.java " to open it in TextEdit). -e                   Opens with TextEdit. -t                   Opens with default text editor. ~/                  Opens with default text editor. In the default editor type out the following code: public class HelloWorld {      public static void main( String [] args) {          System .out.println( "Hello World!" );     } } Press Command+S to save the file and then close the editor. Now compile the program by entering javac Hel

How to Uninstall the JDK & JRE on macOS

Uninstalling the JDK on macOS To uninstall the JDK on macOS: You must have Administrator privileges. Remove the directory whose name matches the following format by executing the rm  command as a root user or by using the sudo tool: /Library/Java/JavaVirtualMachines/jdk-major.minor.security.patch.jdk For example, to uninstall jdk 17.0.1: % sudo rm -rf /Library/Java/JavaVirtualMachines/jdk17.0.1.jdk Uninstalling the JRE on macOS To uninstall the JRE on macOS: You must have Administrator privileges. Remove the JavaAppletPlugin.plugin directory by executing the rm command as a root user or by using the sudo tool. % sudo rm -rf /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin Remove the  JavaControlPanel.prefpane   directory by executing the  rm   command as a root user or by using the  sudo   tool. % sudo rm -rf /Library/PreferencePanes/JavaControlPanel.prefPane % sudo rm -rf ~/Library/Application\ Support/Oracle/Java Note: Do not uninstall Java by removing the Java tools from /usr

How to download, install & set $JAVA_HOME on macOS

This article shows you how to download, install and set the $JAVA_HOME on macOS. Download the Java JDK , for example  jdk-8u321-macosx-x64.dmg. Steps to set the $JAVA_HOME environment variable on macOS. Find out your macOS version. Find out which shell you are using, bash or zsh? For zsh shell, export $JAVA_HOME at  .zshenv  or   .zprofile  or  . zshrc   For bash shell,  export $JAVA_HOME at  .bash_profile or  .bashrc  Source with  source .zshenv Test with  echo $JAVA_HOME Done. Find out your macOS version Click on  the    icon in your Mac. Click on ' About this Mac '. Find out which cell you are using, bash or zsh? On macOS 10.15 Catalina and later, the default terminal shell switch from the   bash  (Bourne-again shell) to   zsh  (Z shell). For bash shell , we can put the environment variables at   .bash_profile  or   .bashrc  For zsh shell, we can put the environment variables at     .zshenv   or    .zprofile   or   . zshrc   To know, your default Terminal shell open