Sunday, October 13, 2019

AHT Fix - restore the Apple Hardware Test on your (old) Mac

This article applies to you only if you have an old Mac that was released before June 2013. Yes, this article is about old hardware that is still out there. It is even still traded on ebay for exmaple. So I am pleased to announce AHT Fix. The tiny app restores the Apple Hardware Test on older Macs (released before June 2013) where Mac OS X, OS X or macOS has been reinstalled from scratch. Please also have a look at the "Implementation details and credits" in this article.

The Problem

„Apple Hardware Test (AHT) contains a suite of diagnostics that will test the hardware of your computer. […] If your Mac was released after June 2013, you will use Apple Diagnostics rather than Apple Hardware Test (AHT).“ See also https://support.apple.com/en-us/HT201257

If you have reinstalled an older Mac from scratch, the diagnostic tools might no longer be available. If there is content in /System/Library/CoreServices/.diagnostics you are affected. Unless you have the original disks that came with your Mac, there seems to be no way to restore the AHT.

The Solution

AHT Fix. You can grab a copy from https://github.com/jonelo/ahtfix

The application will determine the model of your Mac, query an Apple server, download the appropriate AHT binaries and restore it on your Mac. And once restored you just need to follow the instructions at https://support.apple.com/en-us/HT201257 in order to perform all hardware diagnostics on your Mac.

Note: Starting with El Capitan (OS X 10.11) there is a new feature called System Integrity Protection (SIP) that prevents the modificaiton of a number of operating sytem directories by default.
In order to use AHTFix on El Capitan and later you have to disable SIP temporarily.
See also https://www.macworld.com/article/2986118/security/how-to-modify-system-integrity-protection-in-el-capitan.html

System Requirements

  • A Mac, released before June 2013
  • Mac OS X 10.6 or later
  • SIP disabled if you run El Capitan (OS X 10.11) or later
  • An internet connection (any bandwidth)

Implementation details and credits

On https://github.com/upekkha/AppleHardwareTest you find detailed instructions from Claude Becker how to restore the AHT manually. I put those instructions (and a few more) to a bash script so that you can restore the AHT in a comfortable way.

I also would like to thank Apple for hosting the AHT binaries on their servers. That really helps users to restore the AHT on Macs that would be otherwise incomplete.



Saturday, January 19, 2019

How to create a .jar association for your OpenJDK

From Java 11, Oracle has changed the license of their JDK, so you probably may want (or even have) to move to OpenJDK, and if you have moved already to OpenJDK, you may have noticed that clicking on a .jar didn't work anymore as it did with Oracle JDK binaries. This is because most of the pre-build OpenJDK binaries are coming without an installer on Microsoft Windows. Fortunately, it is easy to fix - with jarfix.

In the following example I show you how to use jarfix in order to setup the .jar association for your OpenJDK.


1. Download the OpenJDK

Download the OpenJDK from the source of your choice. You could get it from http://jdk.java.net/ or https://adoptopenjdk.net for example. Actually there are many more sources where you can get it, but I have downloaded the latest OpenJDK from https://adoptopenjdk.net, and extracted the .zip file to C:\Applications\jdk-11.0.1+13


2. Download jarfix

Download jarfix.exe from the jarfix homepage and store the .exe on a folder of your choice on your harddrive. On my Windows instance, I have stored the jarfix.exe to C:\Applications\jarfix\




3. Create a jarfix config file

Create a jarfix.ini file to C:\Applications\jarfix\ with the following content:

[jarfix]
options=/a
action="C:\Applications\jdk-11.0.1+13\bin\javaw.exe" -jar  "%1" %*


Those entries tell jarfix to setup a .jar association with the OpenJDK in C:\Applications\jdk-11.0.1+13\ - you may want to modify that path according to the actual path that you have choosen at step 1. The line called "options=/a" is optional, it tells jarfix to create a "Open as Administrator" menu entry in order to run .jar files also under the Admin account.

Hint: you can run jarfix /x in order to extract an example jarfix.ini file which has a lot of useful examples for a Java developer on Windows.

Update January 27, 2019: from Jarfix version 3 you can recreate hijacked .jar associations out of the box (by a double click without an .ini file) not only for the Oracle JDK, but also for the OpenJDK from Azul Systems.



4. Run jarfix using the config file

Open a Windows Command Prompt or simply hit both the Windows Key and R in order to enter the following command:

C:\Applications\jarfix\jarfix.exe /c


Update January 27, 2019: from Jarfix version 3 it is not necessary anymore to pass the option /c as a parameter. If a .ini file exists with the same name as the .exe in the same directory, jarfix will read the .ini file in order to initialize itself with the values from the .ini. In other words, you can simply double click on jarfix.exe and the content of jarfix.ini will be taken into account.








5. Test it

If you have run "jarfix /x" at step 3, you can double click on the existing jartest.jar in C:\Applications\jarfix in order to test whether it works as expected:




As you can see above we have launched the OpenJDK from AdoptOpenJDK by double-clicking on a .jar file.