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

Use .htaccess mechanism to redirect trafic with Apache [Apache-1]

When you create a website, you may want to store all the content in a dedicated directory. The plus with this way of doing is the ability to easily change for future versions of your blog. You will just have to play with the directory by moving, renaming, etc.

The problem when you do that, is to redirect the users from the root address to this directory.

If your web server is Apache, which is more than probable when you see the usage of web servers for websites.

Then you can create an configuration file named .htaccess with the following content at the root of your domain:

RewriteEngine On
RewriteRule ^$ /blog [L]

^ at the second line mean the beginning of the line, and $ means the end. Their combination means redirect the whole line (aka the actual URL) to the blog directory. The [L] at the end stands for this rule is the last you will read. Redirect now !

Here is the documentation.

In my case, all the connection made to http://www.software-crafting.com will automatically be redirected to http://www.software-crafting.com/blog.

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”


[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.