Omarrr

Fixing Amazon’s Kindle Previewer in El Capitan

For some reason getting Amazon’s Kindle Previewer to work on El Capitan is not an easy task. There are a few resources online that pointed in the right direction but didn’t fully solve the problem for me. Here is what worked for me, extracted from the Amazon forums‎.

Amazon Kindle Previewer

1. Install X11 and Java for OSX

Downloads:

2. Open the Launcher shell script with a text editor

The Launcher file is located in /Applications/Kindle Previewer.app/Contents/MacOS/Launcher.

Go to Finder → Applications → Kindle Previewer.app, right click the file, Show package contents → Contents → MacOS → Launcher, right click the file, Open with → other, choose TextEdit or your favorite text editor.

3. Edit the Launcher file

First add the following line below #!/bin/sh:

export JAVA_HOME="/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home"

Then replace the two occurrences of java -d32 with ${JAVA_HOME}/bin/java -d32.

The new file should look like this:

#!/bin/sh
export JAVA_HOME="/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home"

dir=`dirname "$0"`
cd "$dir"
classpath=./:./lib/touchLibs/etc/fonts/fonts

for i in `ls ./lib`
do
    classpath=$classpath:./lib/$i
done

export DYLD_LIBRARY_PATH=.

# start the previewer
fileExtT=`echo $1 | awk -F. '{print $NF}'`
fileExt=`echo $fileExtT | tr '[:upper:]' '[:lower:]'`

if [ "$fileExt" == mobi -o "$fileExt" == azw3 -o "$fileExt" == epub -o "$fileExt" == opf -o  "$fileExt" == html -o  "$fileExt" == zip ]
then
    # opens only the first book in command line.  TODO: handle multiple books in command line
    ${JAVA_HOME}/bin/java -d32 -XstartOnFirstThread -Dfile.encoding=UTF-8 -cp "${classpath}" com.amazon.epub.reader.Main "$1"
    exit 1
else
    ${JAVA_HOME}/bin/java -d32 -XstartOnFirstThread -Dfile.encoding=UTF-8 -cp "${classpath}" com.amazon.epub.reader.Main
    exit 1
fi

4. Save the changes

You are done.

If you still run into issues it could be that a java process or a previous Kindle Previewer process is still running in the background and preventing the changes from taking effect. Kill the zombie processes (in the terminal or restarting your computer), and things should work now.

Good luck!

December 27, 2015 ☼ code