Showing posts with label mac osx. Show all posts
Showing posts with label mac osx. Show all posts

Monday, September 27, 2021

Install multiple versions of JDK and switch between them via CLI on MAC OSX:

(Updated to include newer JDK versions)

1.11: https://www.oracle.com/java/technologies/javase/jdk11-archive-downloads.html
1.17: https://www.oracle.com/java/technologies/downloads/#JDK17


2) Add the following to the ~/.bashrc or ~/.zshrc
#Set JAVA_HOME to latest version of JAVA_HOME (recommended)
export JAVA_HOME=$(/usr/libexec/java_home)
 

#Set alias options to dynamically change JAVA_HOME to particular JDK
alias jdk6=
' export JAVA_HOME=$(/usr/libexec/java_home -v 1.6.0) '
alias jdk7=' export JAVA_HOME=$(/usr/libexec/java_home -v 1.7.0) '
alias jdk8=' export JAVA_HOME=$(/usr/libexec/java_home -v 1.8.0) '
alias jdk11=' export JAVA_HOME=$(/usr/libexec/java_home -v 11) '
alias jdk17=' export JAVA_HOME=$(/usr/libexec/java_home -v 17) '



3) To switch between the versions of JDK, run the command jdkXX, for example:

#Default version as listed above will always set the JAVA_HOME to the latest version as determined by java_home:
$ java -version
java version "1.8.0_60"
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)
 

$ jdk6
$ java -version
java version "1.6.0_65"
Java(TM) SE Runtime Environment (build 1.6.0_65-b14-468-11M4833)
Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-468, mixed mode)
 

$ jdk7
$ java -version
java version "1.7.0_72"
Java(TM) SE Runtime Environment (build 1.7.0_72-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.72-b04, mixed mode)

jdk11
$ java -version
java version "11.0.11" 2021-04-20 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.11+9-LTS-194)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.11+9-LTS-194, mixed mode)

$ jdk17
$ java -version
java version "17" 2021-09-14 LTS
Java(TM) SE Runtime Environment (build 17+35-LTS-2724)
Java HotSpot(TM) 64-Bit Server VM (build 17+35-LTS-2724, mixed mode, sharing)



Wednesday, April 4, 2018

com.apple.preference.displays.MirrorDisplays): Service only ran for 0 seconds. Grrrrrr.




I've had my Mac Pro 6,1 for a few months and noticed that the display crashes every few weeks, where the symptoms range from 1) screen is "frozen as-is", 2) while mouse cursor can move 3) Cannot click on anything on the screen. 4) System clock on screen is stuck at the time the displays froze, and 5) System is still responsive through SSH.

While there was some discussion on various boards about the issue being due to the AMD FirePro D500 and D700 cards, I have a pair of D300s in this unit, which aren't supposed to be impacted by the known Apple Issue.


This occurred again recently and after getting some time to dig into things further, I looked into /var/log/system.log file to see what was the most recent entries prior to the latest freeze episode.

Found the following:

Output snippet from /var/log/system.log
Apr  4 11:01:18 macpro com.apple.xpc.launchd[1] (com.apple.preference.displays.MirrorDisplays): Service only ran for 0 seconds. Pushing respawn out by 10 seconds.
Apr  4 11:01:28 macpro com.apple.xpc.launchd[1] (com.apple.preference.displays.MirrorDisplays): Service only ran for 0 seconds. Pushing respawn out by 10 seconds.
Apr  4 11:01:38 macpro com.apple.xpc.launchd[1] (com.apple.preference.displays.MirrorDisplays): Service only ran for 0 seconds. Pushing respawn out by 10 seconds.
Apr  4 11:01:58 macpro com.apple.xpc.launchd[1] (com.apple.preference.displays.MirrorDisplays): Service only ran for 0 seconds. Pushing respawn out by 10 seconds.
Apr  4 11:02:28 macpro com.apple.xpc.launchd[1] (com.apple.preference.displays.MirrorDisplays): Service only ran for 0 seconds. Pushing respawn out by 10 seconds.


In digging around the web, found the above link on Stackexchange that talks about this issue being related to a particular issue with out an Apple plugin is behaving badly, and lists instructions on how to temporarily disable it:

Here's the overall steps taken:
Sourced from Stackechange article:
https://apple.stackexchange.com/questions/304745/mirrordisplays-error-every-30-seconds-in-system-log



  1. Disable System Integrity Protection so you can edit the .plist file. Do this by rebooting into the recovery partition with cmd-R, open Terminal from the Utilities menu, and type:
    $ csrutil disable
  2. Reboot, then edit the .plist file with this command:
    $ sudo vi /System/Library/LaunchAgents/com.apple.preference.displays.MirrorDisplays.plist
  3. Comment out the line that causes the MirrorDisplays tool to load. Change this line:
       
  4. To this:
  5. Then, reboot and re-enable System Integrity Protection using the recovery partition as described above and type:
    $ csrutil enable
  6. Reboot 

After implementing the changes, it appears that this has stopped the occurrence:


$ grep "MirrorDisplays): Service only ran" system.log | cut -d ':' -f1 | uniq -c

 164 Apr  4 11

 172 Apr  4 12
  47 Apr  4 13
   3 Apr  4 14

The above command is grepping the system.log for the event occurrence, then parsing based on the first colon ':' which filters out everything of the error past the Day and Hour. So the above output shows that at 11am it occurred 164 times, 12pm occurred 172 times, 1pm 47 and so on...

It's now almost 4pm and no occurrences since disabling!  Keeping fingers crossed that this will fix the freezing scenario, otherwise will continue trudging through the system.log file on the next freeze.


Friday, November 4, 2016

Quick and Dirty Web Service (to serve Parcels and Packages) from a Mac

The following command can be run from a Mac to allow service to run a simple Web server to allow connectivity to access the files located on /path/to/parcels.  Very useful for spinning up a quick CM/CDH repro cluster and needing to post a repo to host CM/CDH/Other parcels.  

$ cd /path/to/parcels; ifconfig | grep inet; sudo python -m SimpleHTTPServer 80

(Originally sourced from: http://lifehacker.com/start-a-simple-web-server-from-any-directory-on-your-ma-496425450, modified to fit this use-case)


The breakdown of the above command:
1) Change dir to the specified location to share/make available
2) Report all of the available network interfaces and display their IP address
3) Run the python package for SimpleHTTPServer on port 80.

Saturday, September 17, 2016

Install Mac OSX El Capitan to a USB stick via CLI


On the command line, copy and paste the following.  NOTE: Substitute the path of the actual USB stick in place of  /Volumes/:

sudo /Applications/Install\ OS\ X\ El\ Capitan.app/Contents/Resources/createinstallmedia --volume /Volumes/ --applicationpath /Applications/Install\ OS\ X\ El\ Capitan.app


Sourced from:
http://www.macworld.com/article/2981585/operating-systems/how-to-make-a-bootable-os-x-10-11-el-capitan-installer-drive.html




Thursday, May 19, 2016

Mac OSX (El Capitan) Software Update tool via CLI


List available software updates via CLI (but don't install them):

$ sudo softwareupdate -l
Software Update Tool
Copyright 2002-2015 Apple Inc.

Finding available software
Software Update found the following new or updated software:
   * OS X El Capitan Update-10.11.5
OS X El Capitan Update (10.11.5), 740450K [recommended] [restart]
   * RAWCameraUpdate6.19-6.19
Digital Camera RAW Compatibility Update (6.19), 7575K [recommended]
   * iTunesXPatch-12.4
iTunes (12.4), 144804K [recommended]



Install all pending software updates via CLI:

$ sudo softwareupdate -i -a
Software Update Tool
Copyright 2002-2015 Apple Inc.

Finding available software

Downloading OS X El Capitan Update
Downloading Digital Camera RAW Compatibility Update
Downloading iTunes
Downloaded Digital Camera RAW Compatibility Update
Downloaded iTunes
Downloaded OS X El Capitan Update
Installing OS X El Capitan Update, Digital Camera RAW Compatibility Update, iTunes
Done with OS X El Capitan Update
Done with Digital Camera RAW Compatibility Update
Done with iTunes
Done.

You have installed one or more updates that requires that you restart your

computer.  Please restart immediately.

Thursday, February 25, 2016

Useful settings for Mac OS X (Mavericks onward) / Adding GPX files directly to a Garmin Fenix 3

Here's a few settings that I came across [1] that helped make my daily workflow easier while working on a Mac, listed below:

defaults write com.apple.finder AppleShowAllFiles YES
defaults write com.apple.finder QLEnableTextSelection -bool TRUE
killall Finder

Let's cover what they do:

defaults write com.apple.finder AppleShowAllFiles YES

This command above enables the ability to show all hidden files in the Finder, which can be useful for power users (or for those who have a Fenix 3 and need to access the NEWFILES folder in /Volumes/Garmin/Garmin to upload .GPX files [2]).


Do you use the Quick look feature much in OS X?  If not, it's certainly a very useful feature to quickly peek into files on the Finder.  If you do use it and would like to copy and paste frequently from these files (i.e. source files, or general text files), the command below will enable this:

defaults write com.apple.finder QLEnableTextSelection -bool TRUE


Of course, we will need to either logout of the current session or restart the finder.  You can restart the finder by running the following:

killall Finder


In case you want to revert the above settings to default, you can run the following commands respectively:

defaults write com.apple.finder AppleShowAllFiles NO
defaults write com.apple.finder QLEnableTextSelection -bool FALSE
killall Finder


References / Sourced from:

[1] Macworld UK:
How to show hidden files and folders in Mac OS X Finder:

How to select and copy text from Quick Look previews in OS X:

[2] Itamar Latnik's Youtube post: Garmin Fenix 3 - Import a GPX Course

Monday, May 18, 2015

Fix for when iMessage on Mac OSX no longer displays SMS/iMessage photos

Thanks to Ralph Johns for the info on the fix!  Here's a quick and dirty script that can help fix iMessage if it stops displaying jpeg files in Mac OSX (Yosemite*):


$cat fix_imessage.sh
#!/bin/bash

# Set file/paths to check
file_attach='~/Library/Messages/Attachments'
file_symlnk='~/Library/Containers/com.apple.iChat/Data/Library/Messages/Attachments'
target_symlnk='../../../../../Messages/Attachments'

#Start checking
echo Checking $file_attach...
if [ -d $file_attach ]
then
        echo $file_attach is already a folder.
fi

if [ -f $file_attach ]
    then
        echo $file_attach is an unexpected file. Fixing...
        echo Renaming Attachments to Attachments.old...
        mv $file_attach $file_attach".old"
        echo "Creating new Attachments folder..."
        mkdir -m770 $file_attach
fi

echo Checking symlink dependencies...
if [ -h $file_symlnk ]
    then
        echo $file_symlnk symlink ok.
    else
        echo $file_symlnk symlink broken.  Fixing...
        mv $file_symlnk $file_symlnk".old"
        ln -sf $target_symlnk  $file_symlnk
fi

echo Done.
echo Exiting.
exit



*NOTE:  Only tested on OSX Yosemite.  May or may not work on other versions of OSX.

Sunday, October 24, 2010

How to flash .img file on Mac OSX

Command Line Interface
==============
1. Download the desired .img file
2. Open a Terminal (in /Applications/Utilities/)
3. Run diskutil list to get the current list of devices
4. Insert your flash media
5. Run diskutil list again and determine the device node assigned to your flash media (e.g. /dev/disk2)
6. Run diskutil unmountDisk /dev/diskN (replace N with the disk number from the last command; in the previous example, N would be 2)
7. Execute sudo dd if=/path/to/downloaded.img of=/dev/rdiskN bs=1m (replace /path/to/downloaded.img with the path where the image file is located; for example, ./ubuntu.img, /dev/rdiskN is faster than /dev/diskN). If you see the error dd: Invalid number `1m', you are using GNU dd. Use the same command but replace bs=1m with bs=1M.
8. Run diskutil eject /dev/diskN and remove your flash media when the command completes
9. External USB disc drives

Saturday, September 25, 2010

How to get Juniper Networks' VPN client (Network Connect) to work in Snow leopard

After a couple weeks' worth of searching, finally found out the commands to setup Network connect to work with my Mac at home, instead of lugging around all the stuff from work:

- install the Network Connect client.
- run it once. It *will* barf. Just clean up with a paper towel
- Drop into bash, and run the following:

bash-3.2# chmod 755 /usr/local/juniper/nc/6.*/
bash-3.2# mkdir /Applications/Network\ Connect.app/Contents/Frameworks
bash-3.2#

And that's IT!

Sunday, May 23, 2010

Cmds to fix Sony Reader Software on Mac OSX

Sourced from here: http://superuser.com/questions/58305/sony-ebook-library-for-mac-no-longer-displays-its-window

rm -rf ~/Library/Preferences/Sony\ Corporation/Reader/
rm ~/Library/Preferences/fsk/1/com.kinoma.fskin.ktStart-kBook.xml

Friday, February 5, 2010

Migrate a Time Machine backup

Migrate a Time Machine backup

Move to a larger disk without losing your existing backups

Tuesday, November 3, 2009

Mac OS Startup Key combinations for Intel-Macs

Press C during startupStart up from a bootable CD or DVD, such as the Mac OS X Install disc that came with the computer.
Press D during startupStart up in Apple Hardware Test (AHT), if the Install DVD 1 is in the computer.
Press Option-Command-P-R until you hear two beeps.Reset NVRAM
Press Option during startupStarts into Startup Manager, where you can select a Mac OS X volume to start from. Note: Press N to make the the first bootable Network volume appear as well.
Press Eject, F12, or hold the mouse (/trackpad) buttonEjects any removable media, such as an optical disc.
Press N during startupAttempt to start up from a compatible network server (NetBoot).
Press T during startupStart up in FireWire Target Disk mode.
Press Shift during startupStart up in Safe Boot mode and temporarily disable login items.
Press Command-V during startupStart up in Verbose mode.
Press Command-S during startupStart up in Single-User mode.
Press Option-N during startupStart from a NetBoot server using the default boot image.