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 Linix 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.