Saturday, February 7, 2009

Setting path environment variable in OS X Leopard

I do most of my programming using using an IDE, historically I've used Eclipse and recently I've been using NetBeans. IDEs are nice because they will compile code for you automatically each time you save. However, for a current homework assignment for my distributed technologies class, we need to do some command line work. Since Java comes prepackaged with Leopard, most of the command line tools already work. Alas, the wsimport command (web service import) does not work out of the box. Getting this command to work required some short research on my favorite search engine and turns out to be rather easy.

From your Unix Terminal, typing the command "locate wsimport" shows where the command is housed:

The Unix cat command is used to read from, write two, or merge files. Custom environment variables are stored in a hidden file in the root of a user's Home directory called .profile. In Unix, the tilde character (~) is a shortcut meaning Home. Typing "cat ~/.profile" will show the contents of the .profile file, if your computer has one. My computer did not up until this point. Now type "cat>>~/.profile". Now type "PATH=$PATH:/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Commands/". Be careful though because the cat command is still working. Press [control+c] to exit the cat command. Now if you type "cat ~/.profile" you should see the line you just typed:

Close and reopen your Unix Terminal and type "wsimport". The command will run and tell you that you didn't enter enough information for it to do anything usefull and will display its usage information.

No comments:

Post a Comment