Switching between java JDKs versions on Mac OS X [Shell-2]

For some reason, you want to have more than only one JDKs on your machine. So you have made the installations and want to easily switch between them.

JDKs Inventory

On MacOS, once JDKs are installed, they are located in the /Library/Java/JavaVirtualMachines directory. 

[Terminal-2] Switch JDKs - Terminal analysis - 965*319

As you can see in this screenshot, I have the Java 7 and Java 8 versions available on my Mac. But the 1.8 is my default one.

Read more

Search informations in multiple files [Shell-1]

You are searching a file containing some text but don’t remember where this damn file is !

I had this problem while I was trying Drupal on my MacBook Pro. I couldn’t find the php.ini file used by MAMP, and used the following command to help me:

find /Applications/MAMP -name "*.ini" -type f -exec grep -Hn nicolas-xdebug {} \;

This command is pretty much self-explanatory but the important point is that I knew I allready add the parameter “nicolas-xdebug” from a previous test. The options H and n in grep respectively print the name of the file where the pattern is find and the line number.

The result told me that the information I search are:

  • in the file /Applications/MAMP/bin/php/php5.6.10/conf/php.ini
  • at line 1171
  • the full line is xdebug.idekey=”nicolas-xdebug”

/Applications/MAMP/bin/php/php5.6.10/conf/php.ini:1171:xdebug.idekey=”nicolas-xdebug”

[Terminal-1] Search infos in multiple files - php.ini xdebug section

 

I can now update the PHP config file with the parameters needed by Drupal.