No Relation To Blog
Subscribe to the personal musing of Emmanuel Bernard
No more Java Preferences for you!
Java on Max OS X is a moving target to say the least since stewardship has moved from Apple to Oracle. I had a lot of trouble to make Eclipse run on my machine making me feel like a customer of The Soup Nazi in Seinfeld.
Let me explain some changes.
The failure
I tried to run Eclipse Juno on my machine and got the following encouraging error
The JVM shared library /Library/Java/JavaVirtualMachines/openjdk-1.7-x86_64 does not contain the JNI_CreateJavaVM symbol
Eclipse always uses the system default JVM on Mac OS X and as far as I know you can't change that. In theory that's not a big deal, you just have to change the default JVM to use via the Java Preferences application.
No more Java Preferences application
Apple recently removed the Java Preferences application from Mac OS X as they deemed it to be useless. In a sort of twisted way - aka we don't care about developers - they were right.
It has been replaced in the Java Oracle distribution by a panel in System Preferences under the Other category. Well except that this panel only deals with Oracle JVMs. So if you happen to have OpenJDK or any other JVM installed, you can not choose (or "unchoose") them.
The side effect for me was that OpenJDK was selected as the default JVM and this created this user friendly error when starting Eclipse.
Hats off to Henri Gomez for helping me find a
way out. You basically need to
go to /Library/Java/JavaVirtualMachines and remove OpenJDK
sudo rm -fR openjdk-1.7-x86_64
In my case I actually moved it somewhere else. What if I want to use OpenJDK too? F**k you! told me Orapple.
The combination of:
- Apple stopping bundling the JVM
- Oracle coming up with an Oracle only replacement
- Apple removing a useful tool
makes the open JDK community at large feel quite unwelcome. So much for an open source project and community where both Apple and Oracle are major stakeholders.
By the way that's not the only glitch I've experienced when moving from the
Apple VM to Oracle VM. JAVA_HOME now points to the JDK instead of the JRE.
Anyways, moving along.
Installing po2xml and xml2pot on Mac OS X
Hibernate documentation system uses po2xml and xml2pot to build translations. Unfortunately, Homebrew does not have a formula for it and I don't think I have the knowledge to work on such thing.
The solution is to install Macport. There is a nice UI installer. Make sure to chose the one specific to your Max OS X version.
MacPort does change your .bash_profile. Because I want to give
Homebrew's executable priority, I make sure to put Macport
changes after homebrew in the PATH variables.
Update Macport
sudo port -v selfupdate
Then install po2xml. Unfortunately, po2xml does not come as standalone package, you have to install all of KDE
sudo port install kdesdk4
Then wait for freaking ever for everything to compile. By the way, source packaging is not eco-friendly. Think about the amount of CPU needed every time you update some package...
Once that is done, add po2xml and xml2pot to your path
PATH=$PATH:/Applications/MacPorts/KDE4/po2xml.app/Contents/MacOS
PATH=$PATH:/Applications/MacPorts/KDE4/xml2pot.app/Contents/MacOS
And you are good to go!
Customize titles of your terminal window
If you are like me, you use many many tabs in your command line terminal. By the way, iTerm2 is a very nice improvement over the vanilla OS X Terminal app.
To recognize tabs, I like to display the name of the current directory and add the directory it is contained in if more space are left. Open your .bash_profile or .profile file and add the following
function local_dir_and_within {__LAST="${PWD##*/}"
__IN="${PWD%/*}"
__IN="${__IN/#$HOME/~}"
TITLE_TAB="$__LAST in $__IN"
echo -n $TITLE_TAB
}
export PROMPT_COMMAND='echo -ne "\033]0;$(local_dir_and_within)\007"'
Your tab title will now look like hibernate-search in ~/code.
iTunes vs incoming connection and VPN vapors: fixes for unApple behaviors
I've just found solutions to two nagging problems I had on Mac OS X.
iTunes and incoming connection requests
Some times ago, iTunes has started to ask me every time it launches "Do you want the application “iTunes.app” to accept incoming network connections?". It gets quickly annoying.
There is a very simple solution. Move iTunes.app (from /Applications) to your trash, download iTunes and install it. The first time you start it, iTunes will ask you to change your firewall settings. Do so and you will be good to go.
If you want to know the tiny details, somehow your iTunes package got changed or corrupted and the firewall was not trusting iTunes anymore.
VPN connection after sleep
Another problem I had was that after the laptop goes to sleep, it is sometimes impossible to reconnect to a VPN. If that happens, you need to restart the right daemon. Open a terminal and run
sudo launchctl stop com.apple.racoon
sudo launchctl start com.apple.racoon
You are now able to connect to your VPN again.
Automatically lock your computer when you go away
If you are like me, your colleagues like to pown you when you leave your laptop unlocked. Here is a super easy solution to lock your Mac automatically when you leave it: if your cellphone is out of bluetooth range, lock your computer. Easy, efficient.
Here is how to do it:
- Download Proximity: this application does detect bluetooth devices and lets you launch scripts upon detection or absence of detection (download page here).
- Copy Proximity.app in /Applications
- Start the Proximity.app and open its preference panel (the application adds itself to the menu bar next to your clock)
- Reduce the device monitoring to 30s or so (less time for your colleagues to mess around)
- Add the device (the device needs to be linked with your computer bluetooth, you can do that in System Preference)
- Add an AppleScript that will be run when your cellphone goes out of range (see below)
- Optionally add an AppleScript that will be run when your cellphone goes back in range
The AppleScript to lock your computer is pretty simple. Create a file name out-of-range.scpt and add:
-- out-of-range.scpt tell application "ScreenSaverEngine" to activate
You can do many more things in these AppleScripts like:
- change your Adium and Skype status
- unlock your screen when you come back in range
This other blog entry has a fairly compete setting example. I personally purposely do not unlock the screen when I come back in range. It's safer to ask for the password explicitly incase someone... borrows your cellphone.
Unlike some more complex apps, Proximity is pretty simple and does not let you decide at which range a bluetooth device is considered out-of-range. The good thing is that it is pretty soft on your cellphone battery.
JarInspector on Mac OS X
There is a tiny little utility that let's you inspect JAR/WAR/EAR files on the Mac OS platform. The software is available here. Install it. To open a JAR, simply right click and chose JarInspector as the application. I personally did not set JarInspector as my default .jar application to let the default JAR launcher kicks in but I have been very close to.
Amongst the useful features:
- navigate in your jars recursively
- edit/view files (useful for MANIFEST.MF)
- decompile a class
- find a file/class by name
By the way, this utility also opens zip files.
Enjoy.
TimeMachine backs up too much?
I just discovered the reason why TimeMachine was backing up so much data. I forgot to exclude my Maven and Ivy repositories :o)
Here is a good tip to discover which files are backed up. You need to have the Developer Tools installed.
When TimeMachine backs up
- Launch /Developer/Applications/Instruments
- Select File Activity
- Open the default target combo box and attach the backupd process.
- Start recording
- Enjoy the list.
I wish there were a less geeky solution.
Mac OS X Leopard and internet downloads
If Leopard asks you if "you are sure you want to open this application which was downloaded from the web" every single time, read further.
I installed Mac OS X Leopard yesterday. Leopard started to warn me about applications downloaded from the Internet. Every single time I open them (not only the first time) I have to confirm it's a safe app.
I first thought Apple believed I was both stupid (can't take care of my security) and with huge memory issues (yes I am trying to open this troyan app 8 times in a row, thank you for reminding me I forgot).
Apparently, this is a small bug. If you download an application with one user account but do not open it with the same account, the security flag is never lift up. To work around that, log on your original account, open all you downloaded apps (27 for me, the dock was a nice christmas tree :) ), accept the security warning for all of them. Next time you open one of them, the security warning will not appear, pfffeu!
Another tip for free. If, like me, you want your old iLife applications back after a clean OS install, go download Pacifist, extract the iThing packages from the Tiger CDs and install them.
It was nevertheless the smoothest clean reinstall experience I've ever had (Carbon Copy Cloner and the Migration Assistant are fantastic).