Archive for the ‘Howto’ tag
Moving From Eclipse to Intellij on the Mac
I have been using Eclipse for the past 5 years. During that time, there have been projects where I have been exposed to Intellij. Recently, after a conversation with a colleague, they convinced me to give the latest and greatest Intellij a try. They bragged about the wonderful Spring integration and code inspection. So I decided to give it a try. After using it for about a month now, I must admit, I have seen the light. It took a while to get used to the different keyboard shortcuts even though Intellij has the default Eclipse key bindings available as a selection. I decided to do a clean break from Eclipse, and learn the new keys.
Since I develop on the Mac, there was one HUGE problem for me with Intellij, but I am not sure if it is an Intellij or a OS X problem. I want to be able to map cmd-space to content assist. For some reason, every time I hit cmd-space in Intellij, I just get a system level beep. On my Mac Pro at home, it is not really an issue, since I have a full keyboard, and I have a ctrl key on the right side of the keyboard. On my Macbook Pro I do not, and it is very awkward for me to have to move my left hand to try to find the ctrl key. I am SO used to using my right hand for ctrl, it was starting to become painful.
I looked around to try to figure out a way to create the key binding with no luck. I tried to remap ctrl-j to it, but then it looses the live template content assist. If I can use ctrl-j for both of them, that would not be so bad. I also tried to find a system level solution, that would allow me to override the cmd-space limitation in Intellij with no luck.
Finally… One morning I was looking at my keyboard, and I noticed this somewhat useless key on the right hand side of my keyboard called the “enter” key. What is that? Why do I need two enter keys? Oh, I see, if I want to use the “numeric” keypad on the keyboard, it would be useful to have an enter key there. What am I an accountant?
I started thinking, if I can remap the useless enter key to be a ctrl key, my problems would be solved. Low and behold I found Double Command. What an totally useful program. It allowed me to remap the enter key to be a ctrl key.
Problem Solved.
Connecting to a corporate network with a Mac
Today was my first day at work with the new MacBook. Going in to today, I had several concerns on my mind, but after a little bit of work, and some patience, I was able to connect to all of the essential corporate resources. Here is a break down of the concerns I faced going in, the actual issues I ran in to, and what I did to work around them.
Connecting to the Exchange Server Result:Success
I knew that this would be pretty much hit or miss. I have heard both negative, and positive reactions with respect to connecting MS Entourage to a corporate MS Exchange server.
Configuration – Set up a new Exchange account, configured it to point to the corporate Exchange server. Hit send/receive. Done. All of my mail, meetings, contacts, filters, and folders were instantly downloaded.
Connecting to NFS Mounts Result:Success
Originally, I tried to mount the NFS shares via SMB using the following command: mount -t smbfs -o username=user //server/share /mnt/mymount/ – No Good. It said that the smbfs does not support the “-o” option. Doesn’t support the “-o” option? Then how am I supposed to pass my username?
After some minor searching on Apple’s site, turns out that Apple was nice enough to provide us with a specific command for this task called mount_smbfs. After reviewing the Man page I came up with the following command mount_smbfs -Uusername //server/share ~/mnt/mymount. After executing the command, I was prompted for my password. I entered my password, and then the mount point was active.
Connecting to Network Printers Result:Success
I haven’t tried to connect to my network printer at home yet, so I had no idea if I would be able to connect to the printer at work. I went in to the print and fax settings. Clicked on the ‘+’ to add a printer. First I selected an IP Printer. Then I was asked to choose between a HP Jet Direct or LPD protocol. First I chose, HP Direct, since the printer I was trying to connect to was an HP printer. No Luck. When I tried to print it said that the printer was busy even though it said Idle under the status icon. So I went back and tried the LPD protocol. For the Address, I gave the Printer Server, for the Queue, I gave it the printer name. I then selected the type of HP printer that it is from the list. I tried to print again. Success.
To be honest, it was quite un-eventfull. After hearing so many people speak about how difficult it is to integrate a Mac in to a corporate environment, it just seemed so easy to me. Of course there are a few more issues that I have to work out, but overall, I am good to go.
Directory size from the cmd line
Have you ever wanted to scan recursively through a directory to find out how much space each sub directory was taking up? Well, there is an easy way of doing this on *nix. Just run du “Disk Usage”.
On a Darwin (OS X) based distro you can run:
du -hd1
which tells du to render the results in [h]uman readable format and to traverse a max depth of 1.
To achieve the same results on a Linux based distro you can run
du -h --max-depth=1
For further information (rtfm) refer to the man page.
Configuring a Java Development Environment on OS X Tiger
Since I just received my new MacBook Pro, I am tasked with setting up my development environment. Since most of my development is Java/Java EE based, the first thing I need to do is decide on the file system layout for all of the Java artifacts. I.e., JDK, IDE’s, Open Source Packages, App Servers, etc… I also need to decide on how I will control the Java runtime environment. I.e., Run App Server under Java 5, run a build under Java 1.4, run a Java Swing app under yet a different virtual machine. Here are my thoughts on each of these:
File System Layout
There are several options available here. Typically I like to do things in a industry standard type way, but after hours of searching on Google, I was not really able to find a “Standard” way for laying out the file system. Thus, it looks like I will need to come up with my own personal layout.
Option 1: Use the Apple Paradigm
When you run a fresh in install of OS X Tiger, you get several JDK’s pre-installed. They are located under: /System/Library/Frameworks/JavaVM.framework/Versions. Under Versions, you will find each installed VM there. On mine I have 1.3.1, 1.4.2, and 1.5.0. I will talk about how to reference each of these in the next part of this article. Ok, now we know where the JDK’s are installed. I think this directory structure will suit my needs just fine.
The next thing I need to figure out is where to install my IDE’s to. I really shouldn’t say “IDE’s” because there is really only one IDE that I need to install, which is Eclipse. The other IDE I am referring is Apple’s XCode, but the installer for this package comes with the Tiger DVD. I installed it to Apple’s default location which is: /Developer/Applications. I actually think this directory structure makes a lot of sense because it gives you a way to partition development libraries from “production” libraries. All I mean by “production” libraries are libraries that the OS leverages to run non development applications. The XCode installer also sets up several other directories under /Developer such as /Java, /Tools, /Makefiles, /SDKs, etc.. Wow, it sets up a /Java directory for me to leverage, so it makes figuring out where to place my Java artifacts a lot easier. Thus, here is my planned directory structure:
/Developer/Applications:
I will install Eclipse to here, since Eclipse is a “Developer Application” not just a Java IDE.
/Developer/Java:
I will create three directories under here, namely, Servers, Tools and Frameworks.
/Developer/Java/Servers:
I will place “Servers” here such as Jboss, Weblogic, Tomcat, etc…
/Developer/Java/Tools:
I will place “Tools” here such as Ant, Maven, GCJ, etc…
/Developer/Java/Frameworks:
I will place “Frameworks” here such as, Apache Loj4J, XMLBeans, BeanUtils, Xerces, Hibernate, Boss Seam, etc…
Option 2: Use the Unix/Linux Paradigm
Ah, yes the good old *Nix paradigm. It is actually quite simple. Under this paradigm there is one main directory that holds everything Java. It is: /usr/local
/usr/local/jdk1.x.x:
This is where I will place all of my JDK’s.
/usr/local/jboss.x:
This is where I will place all of my Java Servers.
/usr/local:
I will create a directory called /eclipse and install Eclipse here. I will also create a directory called /java/lib and /java/tools.
/usr/local/java/lib:
This is where I will place all of my “Frameworks” This directory is equivalent to the “Frameworks” directory above.
/usr/local/java/tools:
This is where I will place my “Tools” such as Ant and Maven.
That sums up 2 potential layouts. Personally I am going to go with Option 1 for several reasons, namely, OS X is not *Nix, thus it deserves a directory structure that works best for it. Also, I have been using the *Nix paradigm since I have been developing, and sometimes it is nice to change things up a little bit. With that said, you can see that these two directory structures are so similar, you must be thinking what is the difference? Once scenario uses /usr/local as a base and the other uses /Developer/Java? Physically, there is not much separating the two. Logically, The Apple paradigm makes a lot more sense, because of the pseudo development partition. I think it keeps things neat an organized.


