Mountain Lion came with a version of apxs where C compiler and pre-processor are defined to a location not in phase with XCode 4.5.
If you try to build any apxs related modules or Tomcat Native Library, it will fail like this :
1234567891011121314151617181920
checking build system type... x86_64-apple-darwin12.2.0
checking host system type... x86_64-apple-darwin12.2.0
checking target system type... x86_64-apple-darwin12.2.0
checking for a BSD-compatible install... /usr/bin/install -c
checking for working mkdir -p... yes
Tomcat Native Version: 1.1.24
checking for chosen layout... tcnative
checking for APR... yes
setting CC to "/Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.8.xctoolchain/usr/bin/cc" setting CPP to "/Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.8.xctoolchain/usr/bin/cc -E"checking for JDK location (please wait)... /System/Library/Frameworks/JavaVM.framework/Versions/A/
checking Java platform... checking Java platform...
checking for sablevm... NONE
adding "-I/System/Library/Frameworks/JavaVM.framework/Versions/A//Headers" to TCNATIVE_PRIV_INCLUDES
checking os_type directory... jni_md.h found in /System/Library/Frameworks/JavaVM.framework/Versions/A//Headers
checking for gcc... /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.8.xctoolchain/usr/bin/cc
checking whether the C compiler works... no
configure: error: in `/Users/henri/tomcat-native-1.1.24-src/jni/native':configure: error: C compiler cannot create executablesSee `config.log'for more details
apxs get its configurations from /usr/share/httpd/build/config_vars.mk who reference /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.8.xctoolchain.
mbp-rico:native henri$ CFLAGS='-arch i386 -arch x86_64' ./configure --with-apr=/usr --with-ssl=/usr --with-java-home=/System/Library/Frameworks/JavaVM.framework/Versions/A/
checking build system type... x86_64-apple-darwin12.2.0
checking host system type... x86_64-apple-darwin12.2.0
checking target system type... x86_64-apple-darwin12.2.0
checking for a BSD-compatible install... /usr/bin/install -c
checking for working mkdir -p... yes
Tomcat Native Version: 1.1.24
checking for chosen layout... tcnative
checking for APR... yes
setting CC to "/Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.8.xctoolchain/usr/bin/cc" setting CPP to "/Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.8.xctoolchain/usr/bin/cc -E"checking for JDK location (please wait)... /System/Library/Frameworks/JavaVM.framework/Versions/A/
checking Java platform... checking Java platform...
checking for sablevm... NONE
adding "-I/System/Library/Frameworks/JavaVM.framework/Versions/A//Headers" to TCNATIVE_PRIV_INCLUDES
checking os_type directory... jni_md.h found in /System/Library/Frameworks/JavaVM.framework/Versions/A//Headers
checking for gcc... /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.8.xctoolchain/usr/bin/cc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.8.xctoolchain/usr/bin/cc accepts -g... yes
checking for /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.8.xctoolchain/usr/bin/cc option to accept ISO C89... none needed
checking for OpenSSL library... using openssl from /usr/lib and /usr/include
checking OpenSSL library version... ok
checking for OpenSSL DSA support... yes
setting TCNATIVE_LDFLAGS to "-lssl -lcrypto" adding "-DHAVE_OPENSSL" to CFLAGS
setting TCNATIVE_LIBS to "" setting TCNATIVE_LIBS to " -L/usr/lib -R/usr/lib -lapr-1 -lpthread"configure: creating ./config.status
config.status: creating tcnative.pc
config.status: creating Makefile
config.status: executing default commands
OSX is a good platform for Java development but also running Java applications. Sadly XServe servers are no more available but in many cases Mac Mini could to pretty good works as Java server applications.
For a long time, OSX Java was maintained by Apple, from Sun Hotspot and was often a bit late vs Windows/Linux releases.
With Lion, Apple announced that they won’t produce Java for their futures OS, starting with Mountain Lion (10.8) and Oracle will do the job as they did for major distributions.
OpenJDK project included OSX support more than one year ago and there is now a very good coverage of Java for OSX.
It take some time to see first official Java 7 from Oracle on OSX, for Lion only, but there was community alternatives like openjdk-osx-build, where you could find a large choice of OpenJDK for OSX (7, 8, 8 with Lambda, 8 with Jigsaw).
If you install Java’s from Oracle or openjdk-osx-build, you may want to know how to select one of them for your application and even select a specific one for some of your applications.
Java Preferences
Apple provide a good tool to select default JVM, Java Preferences :
In this screenshot you could see many JVM, from many sources, Apple, Oracle and openjdk-osx-build and default ordering Java (from up to bottom).
Here you’ll see that default JVM will be Apple Java 1.6.0_33-b03-424 in 64bits, next choice will be Apple Java 1.6.0_33-b03-424 in 32bits. You will notice these JVM are marked as System, more on this later.
Next you’ll find Apple Java 1.6.0_31 in 64 and 32 bits and then Java 1.7 (1.7.0-jdk7u6-b20-20120719) from openjdk-osx-build. By the end you’ll find latest official Oracle Java 7, aka 1.7.0_05.
What does it means for you in a command line mode, console is just mandatory for any serious OSX geek ?
Let see java used by default :
1234
mbp-rico:~ henri$ java -version
java version "1.6.0_33"Java(TM) SE Runtime Environment (build 1.6.0_33-b03-424-11M3720)Java HotSpot(TM) 64-Bit Server VM (build 20.8-b03-424, mixed mode)
Default Java is Apple 1.6.0_33, 64bits as expected, so far so good.
What should i do if I want to select instead Java 7 ?
Standard Unix way
You could just update your PATH environment variable to update search path :
12345
mbp-rico:~ henri$ export PATH=/Library/Java/JavaVirtualMachines/1.7.0u6.jdk/Contents/Home/bin:$PATHmbp-rico:~ henri$ java -version
openjdk version "1.7.0-jdk7u6-b20"OpenJDK Runtime Environment (build 1.7.0-jdk7u6-b20-20120719)OpenJDK 64-Bit Server VM (build 23.2-b09, mixed mode)
It works but OSX provide smarter mechanism.
OSX way
Keeping in mind we’re discussing command line operation, updating default JVM via Java Preferences will not be retained, will define instead JAVA_HOME environment variable like this :
12345
mbp-rico:~ henri$ export JAVA_HOME=/Library/Java/JavaVirtualMachines/1.7.0u6.jdk/Contents/Home/
mbp-rico:~ henri$ java -version
openjdk version "1.7.0-jdk7u6-b20"OpenJDK Runtime Environment (build 1.7.0-jdk7u6-b20-20120719)OpenJDK 64-Bit Server VM (build 23.2-b09, mixed mode)
We could keep our current PATH and it will be Apple java bootstrap system, living into /usr/bin/java who make use of JAVA_HOME and launch the proper JVM. Simple but efficient .
java_home
As we see previously, Java Preferences define an order of preferred JVM on OSX, like alternatives does on many Linux systems, especially those using JPackage tooling. So there should be a way to get access to these preferences and here entering java_home
java_home is located in /usr/libexec and has many useful features :
123456789101112131415
mbp-rico:~ henri$ /usr/libexec/java_home --help
Usage: java_home [options...] Returns the path to a Java home directory from the current user's settings.
Options:
[-v/--version <version>] Filter Java versions in the "JVMVersion" form 1.X(+ or *).
[-a/--arch <architecture>] Filter JVMs matching architecture (i386, x86_64, etc).
[-d/--datamodel <datamodel>] Filter JVMs capable of -d32 or -d64
[-t/--task <task>] Use the JVM list for a specific task (Applets, WebStart, BundledApp, JNI, or CommandLine)[-F/--failfast] Fail when filters return no JVMs, do not continue with default.
[ --exec <command> ...] Execute the $JAVA_HOME/bin/<command> with the remaining arguments.
[-R/--request] Request installation of a Java Runtime if not installed.
[-X/--xml] Print full JVM list and additional data as XML plist.
[-V/--verbose] Print full JVM list with architectures.
[-h/--help] This usage information.
mbp-rico:~ henri$ /usr/libexec/java_home -v 1.6 -a i386
/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
Obtaining path of default Java 1.6 64 bits JVM :
12
mbp-rico:~ henri$ /usr/libexec/java_home -v 1.6 -a x86_64
/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
Here you could see that 32 and 64bits JVM have the same path. This is because due to universal mode (i386/x86_64), Apple produce a dual mode JVM. This is not the case for Oracle Java 7 where only 64bits JVM is available.
Let’s combine java_home and JAVA_HOME :
12345
mbp-rico:~ henri$ export JAVA_HOME=`/usr/libexec/java_home -v 1.7`mbp-rico:~ henri$ java -version
openjdk version "1.7.0-jdk7u6-b20"OpenJDK Runtime Environment (build 1.7.0-jdk7u6-b20-20120719)OpenJDK 64-Bit Server VM (build 23.2-b09, mixed mode)
This is a very nice features if you want to specify a Java Level (6 or 7) following your Java Preferences for some of your server side application (let say Apache Tomcat) or command operation (like Apache Maven).
Typically for my Apache Tomcat powered application like Jenkins, I usually set it in bin/setenv.sh :
mbp-rico:~ henri$ /usr/libexec/java_home -V
Matching Java Virtual Machines (33):
1.6.0_33-b03-424, x86_64: "Java SE 6" /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
1.6.0_33-b03-424, i386: "Java SE 6" /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
1.6.0_31-b04-411, x86_64: "Java SE 6" /Library/Java/JavaVirtualMachines/1.6.0_31-b04-411.jdk/Contents/Home
1.6.0_31-b04-411, i386: "Java SE 6" /Library/Java/JavaVirtualMachines/1.6.0_31-b04-411.jdk/Contents/Home
1.7.0-jdk7u6-b20-20120719, x86_64: "OpenJDK 7" /Library/Java/JavaVirtualMachines/1.7.0u6.jdk/Contents/Home
1.8.0-jdk8-b47-20120720, x86_64: "OpenJDK 8" /Library/Java/JavaVirtualMachines/1.8.0.jdk/Contents/Home
1.7.0-jdk7u4-b21-20120427, i386: "OpenJDK 7" /Library/Java/JavaVirtualMachines/1.7.0u4.jdk/Contents/Home
1.7.0_05, x86_64: "Java SE 7" /Library/Java/JavaVirtualMachines/1.7.0.jdk/Contents/Home
1.6.0_33-b03-424, x86_64: "Java SE 6" /Library/Java/JavaVirtualMachines/1.6.0_33-b03-424.jdk/Contents/Home
1.6.0_33-b03-424, i386: "Java SE 6" /Library/Java/JavaVirtualMachines/1.6.0_33-b03-424.jdk/Contents/Home
1.8.0-jdk8-b45-20120713-jigsaw, x86_64: "OpenJDK 8" /Library/Java/JavaVirtualMachines/1.8.0-jigsaw.jdk/Contents/Home
1.8.0-b48-20120720-lambda, x86_64: "OpenJDK 8" /Library/Java/JavaVirtualMachines/1.8.0-lambda.jdk/Contents/Home
1.7.0-jdk7u6-b20-20120719, i386: "OpenJDK 7" /Library/Java/JavaVirtualMachines/1.7.0u6.jdk/Contents/Home
1.7.0-jdk7u4-b21-20120427, x86_64: "OpenJDK 7" /Library/Java/JavaVirtualMachines/1.7.0u4.jdk/Contents/Home
1.7.0-jdk7u4-b21-20120421, x86_64: "OpenJDK 7" /Library/Java/JavaVirtualMachines/1.7.0u4-64.jdk/Contents/Home
1.7.0, x86_64: "OpenJDK 7" /Library/Java/JavaVirtualMachines/1.7.0u.jdk/Contents/Home
1.7.0, i386: "OpenJDK 7" /Library/Java/JavaVirtualMachines/1.7.0u.jdk/Contents/Home
1.6.0_32-b05-420, x86_64: "Java SE 6" /Library/Java/JavaVirtualMachines/1.6.0_32-b05-420.jdk/Contents/Home
1.6.0_32-b05-420, i386: "Java SE 6" /Library/Java/JavaVirtualMachines/1.6.0_32-b05-420.jdk/Contents/Home
1.6.0_32-b05-417, x86_64: "Java SE 6" /Library/Java/JavaVirtualMachines/1.6.0_32-b05-417.jdk/Contents/Home
1.6.0_32-b05-417, i386: "Java SE 6" /Library/Java/JavaVirtualMachines/1.6.0_32-b05-417.jdk/Contents/Home
1.6.0_31-b04-413, x86_64: "Java SE 6" /Library/Java/JavaVirtualMachines/1.6.0_31-b04-413.jdk/Contents/Home
1.6.0_31-b04-413, i386: "Java SE 6" /Library/Java/JavaVirtualMachines/1.6.0_31-b04-413.jdk/Contents/Home
1.6.0_30-b12-409, x86_64: "Java SE 6" /Library/Java/JavaVirtualMachines/1.6.0_30-b12-409.jdk/Contents/Home
1.6.0_30-b12-409, i386: "Java SE 6" /Library/Java/JavaVirtualMachines/1.6.0_30-b12-409.jdk/Contents/Home
1.6.0_30-b12-404, x86_64: "Java SE 6" /Library/Java/JavaVirtualMachines/1.6.0_30-b12-404.jdk/Contents/Home
1.6.0_30-b12-404, i386: "Java SE 6" /Library/Java/JavaVirtualMachines/1.6.0_30-b12-404.jdk/Contents/Home
1.6.0_29-b11-397, x86_64: "Java SE 6" /Library/Java/JavaVirtualMachines/1.6.0_29-b11-397.jdk/Contents/Home
1.6.0_29-b11-397, i386: "Java SE 6" /Library/Java/JavaVirtualMachines/1.6.0_29-b11-397.jdk/Contents/Home
1.6.0_27-b07-395, x86_64: "Java SE 6" /Library/Java/JavaVirtualMachines/1.6.0_27-b07-395.jdk/Contents/Home
1.6.0_27-b07-395, i386: "Java SE 6" /Library/Java/JavaVirtualMachines/1.6.0_27-b07-395.jdk/Contents/Home
1.6.0_26-b03-383, x86_64: "Java SE 6" /Library/Java/JavaVirtualMachines/1.6.0_26-b03-383.jdk/Contents/Home
1.6.0_26-b03-383, i386: "Java SE 6" /Library/Java/JavaVirtualMachines/1.6.0_26-b03-383.jdk/Contents/Home
/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
Note on JVM Locations
You may have noticed many differents paths for JVM :
/System/Library/Java/JavaVirtualMachines is where Apple install System JVM. Here you could have only one JVM by family, ie 1.6, 1.7. These JVM will be available to all users on system.
/Library/Java/JavaVirtualMachines is a slot location for guest JVMs, specially designed to host contributors JVM like Oracle, openjdk-osx-build or Apple Developper Preview JVMs Also, these JVM will be available to all users on system.
/Users/bill/Library/Java/JavaVirtualMachines is a slot for contributor JVMs but only available to user bill.
To conclude
OSX is probably the platform with the more choice of Java to run and experiment, Java 6, Java 7, OpenJDK 7, 8, Lambda, Jigsaw.
And with its /usr/libexec/java_home and JAVA_HOME environment variable, you could select any of them for your console or command mode operations very easily.
Updated build process for tomcat-connector, 1.1.24, no more APXS variable or configure parameters required
123456789101112
TCN_RELEASE=1.1.24
curl http://mir2.ovh.net/ftp.apache.org/dist//tomcat/tomcat-connectors/native/$TCN_RELEASE/source/tomcat-native-$TCN_RELEASE-src.tar.gz -o tomcat-native-$TCN_RELEASE-src.tar.gz
tar xvzf tomcat-native-$TCN_RELEASE-src.tar.gz
cd tomcat-native-$TCN_RELEASE-src/jni/native
CFLAGS='-arch i386 -arch x86_64'APXSLDFLAGS='-arch i386 -arch x86_64' ./configure --with-apr=/usr --with-ssl=/usr --with-java-home=/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
make clean
make
sudo cp .libs/libtcnative-1.0.1.24.dylib /usr/lib/java
sudo rm -f /usr/lib/java/libtcnative-1.dylib
sudo ln -s /usr/lib/java/libtcnative-1.0.1.24.dylib /usr/lib/java/libtcnative-1.dylib
A note about Lion
If you get Java on Lion using the java command on terminal or via the Java Developer Package for Mac OS X 10.7, Java headers are not on the usual location and you could find them under /System/Library/Frameworks/JavaVM.framework/Versions/A/Headers
You should then update the configure command line like this :
Benchmark Summary
Integer Score 3123 |||||||||
Floating Point Score 5493 |||||||||||||||| Memory Score 2629 |||||||
Stream Score 2110 |||||| Geekbench Score 3752 |||||||||||
System Information
Operating System Mac OS X 10.7.3 (Build 11D50) Model MacBook Pro (Late 2008) Motherboard Apple Inc. Mac-F42D86A9 Proto
Processor Intel Core 2 Duo T9550 @ 2.66 GHz
1 Processor, 2 Cores, 2 Threads
Processor ID GenuineIntel Family 6 Model 23 Stepping 10
L1 Instruction Cache 32.0 KB x 2
L1 Data Cache 32.0 KB x 2
L2 Cache 6.00 MB
L3 Cache 0.00 B
Memory 8.00 GB 1067 MHz DDR3
BIOS Apple Inc. MBP51.88Z.007E.B06.1202061253
IOs seems to be the limiting factor, especially when I’m using VirtualBox, I feel a slow IO performances.
Time to bench IOs
There is no tools like HD Tune on OSX, so I wrote a very simple shell script to measure raw IO performances.
testing pseudo-IO performances - 1st Pass
2048+0 records in
2048+0 records out
2147483648 bytes transferred in 0.225590 secs (9519410157 bytes/sec)testing IO write performances - 1st Pass
2048+0 records in
2048+0 records out
2147483648 bytes transferred in 29.882202 secs (71864973 bytes/sec)testing IO read performances - 1st Pass
2048+0 records in
2048+0 records out
2147483648 bytes transferred in 0.677308 secs (3170615711 bytes/sec)testing IO read performances - 2nd Pass
2048+0 records in
2048+0 records out
2147483648 bytes transferred in 0.675835 secs (3177527036 bytes/sec)testing IO write performances - 2nd Pass
2048+0 records in
2048+0 records out
2147483648 bytes transferred in 33.203725 secs (64675986 bytes/sec)
Note, I run this performance tests from a directory excluded from Spotlight indexing !
Pseudo IO performance is justing virtual IO (/dev/zero and /dev/null), so it provide max raw IO performance : 9078 MB/s
Write IO performance is between 61 and 68 MB/s
Read IO performance is very high with 3023 MB/s
I replayed script raising COUNT from 2048 to 20480 to reduce OSX ram buffer impact in Read IO performance but still get about 2000 MB/s
iStat Menu disk activity - Write Performance
Conclusions
WD Black Edition perform pretty well on raw sequential Read Operations
With its average 63 MB/s raw sequential Write Operations, WD is about 7 time slower than faster SSD like OCZ Vertex 3
Is it time to update MBP to SSD ? Probably and my candidates are :
Crucial M4 128GB. This SSD is reported very stable and reliable. Bonus, its firmware could be updated from Mac.
OCZ Vertex 3 120GB. This SSD is top performer in benchmarks but Googling it reports many reliability problems.
I’d like to get feedback from you, performing same performance testing on your Mac hardware (MBP/ SSD configurations very welcomed).
If you installed MacFuse on Lion (10.7) and tried to uninstall you may encountered the following error :
12
sudo /Library/Filesystems/fusefs.fs/Support/uninstall-macfuse-core.sh
MacFUSE Uninstaller: Can not find the Archive.bom for MacFUSE Core package.
Uninstaller didn’t check for Lion (uname -r reporting 11.x).
So fix is easy, just edit uninstaller script /Library/Filesystems/fusefs.fs/Support/uninstall-macfuse-core.sh and add 11) in case next to 10)
123456789101112131415161718
...
OS_RELEASE=`/usr/bin/uname -r`case"$OS_RELEASE" in
8*) log "Incorrect uninstall. Use the Tiger version please."exit 1
;;
9*)PACKAGE_RECEIPT="$INSTALL_VOLUME/Library/Receipts/MacFUSE Core.pkg"OUTER_PACKAGE_RECEIPT="$INSTALL_VOLUME/Library/Receipts/MacFUSE.pkg"BOMFILE="$PACKAGE_RECEIPT/Contents/Archive.bom" ;;
10*|11*)PACKAGE_RECEIPT=""BOMFILE="$INSTALL_VOLUME/var/db/receipts/com.google.macfuse.core.bom" ;;
esac