Sunday, January 10, 2010

First of all, get the git bundle.

newtricks:~ ted$ cd ~/Library/Application\ Support/TextMate/Bundles
newtricks:Bundles ted$ git clone git://gitorious.org/git-tmbundle/mainline.git Git.tmbundle
Initialized empty Git repository in /Users/ted/Library/Application Support/TextMate/Bundles/Git.tmbundle/.git/
remote: Counting objects: 5018, done.
remote: Compressing objects: 100% (1612/1612), done.
remote: Total 5018 (delta 3342), reused 4957 (delta 3303)
Receiving objects: 100% (5018/5018), 634.79 KiB | 181 KiB/s, done.
Resolving deltas: 100% (3342/3342), done.
newtricks:Bundles ted$

Then, invoke Textmate and navigate to Bundles->Git->Administration ->Update Git Bundle. The following screen appears.



Here are some references.

http://gitorious.org/git-tmbundle
http://blog.macromates.com/2008/git-bundle/

This Textmate git bundle seems to work pretty well. Here's how I tried it out. First of all use Textmate to open a file that is a member of a git repository. Make a change and save it. Then, from the Textmate window do a Bundles -> Git -> Commit.




Double click on the filename in the Choose files to commit pane. A Textmate window opens up that shows the file in a diff format.



Write a description in the Summary of changes pane. Click commit. The window with the Summary and Commit button disappears and the other window shows what happened.



I still have the two Textmate windows open. Close the one with the diff and select the one with the file. Then, from the Textmate menu do a Bundles -> Git -> Log, and the following window appears.



Git
1/10/2010 12:38:29 PM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |   |  Trackback
 Saturday, January 09, 2010

The one that came with git really doesn't work well. My suspicion is that this problem has more to do with Snow Leopard than the git gui.

Type git gui on the command line. The prompt does not return. The result is variable. Today, nothing happened. Well, I got a git icon in my taskbar. For a while it bounced up and down. Now it is doing nothing. Click on it, and I get the following.



That quit button works. But the menu on the top of my desktop has the Quit Git Gui entry shaded out. In fact, most of the menu entries are grayed-out. I quit by issuing a Control-C in the command window in which I invoked git gui. The prompt returned.

Type git gui again. Now the git screen comes up; remember, it didn't before.

So I click on Open Existing Repository and browse to guess what, an existing repository and click Open.




 

Note the menu bar. It says Git Gui Apple Repository ... Now when it first came up, it didn't look like the figure below. I clicked on Amend Last Commit. This caused the filename to appear in Staged Changes. I then clicked on the filename, and its text appeared in the upper right pane. The change is shown in green.

Two things are key here. One, most of the menu entries are still disabled. Two, the menu bar is what it is. It will change soon.




 

Click on New Commit. Then, right click in the empty space of the upper right pane and choose Options. An options window appears. Click Save. The options window goes away. Now the menu entries are no longer disabled. Sigh. Does this make sense? Not to me.

Click on Repository and from the dropdown, choose Create Desktop Icon. Give the Desktop Icon a name and click Save. Then Click on Git Gui and choose Exit.

Now open the Desktop Icon. Note now that the menu bar entries are different. And now git gui seems to operate as it should.




None of this makes sense to me. This is not the gui I want to use.

So what am I going to use? I installed Textmate's git bundle. So far it looks good. I'll also check out the git plugin for Eclipse.


Git
1/9/2010 11:41:36 PM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |   |  Trackback
 Friday, January 08, 2010
This MAC, you know. I like it, but sometimes I get very frustrated. For example, I click on a text file, and the editor that comes up is TextEdit, not my favorite. Editors are not a big deal for me ... I'm more interested in what is being edited. Nonetheless, when pressed, I prefer vi just because I have used it for years and years.

But with the MAC  it is very difficult to get vi to be the default text editor. There are ways, of course. Check out http://www.macosxhints.com/article.php?story=20080305012955463

But you can't get vi to be the default editor by right clicking on the file in Finder and choosing Open With. Vi is just not there. If you do a which vi, the path returned is /usr/bin/vi. If I look in Finder in Developer/usr/bin, I see no vi. Or vim for that matter.

I can get vi (and vim) to appear in Finder. To do that, I become root and make a symbolic link in / to /usr .. like ln -s /usr tedusr. Then in Finder I click on Macintosh HD and open up my link. I can then drag bin to the sidebar. If I open up bin, I then see vi and vim, and if I click on vi, vi starts up (actually vim starts up because vi is a link to vim).

But now if I right click on a text file and choose Open With and navigate to vi (using the bin in my sidebar), I see vi but it is shaded and I cannot select it.

So what am I doing? I now mostly choose TextMate.app as the editor for text files. This is a commercial editor that is well worth the investment, but sometimes you just want vi. vi is still available from the command line. I can just open a terminal window and navigate to where my text file is and type vi filename. Just like the old days.


Mac
1/8/2010 4:53:08 PM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |   |  Trackback
 Thursday, December 31, 2009

I wanted to try out git on the Mac. I'm reading the book Pragmatic Version Control Using Git by Travis Swicegood. There's a forum discussing this book on the Pragmatic Programmer's site, http://forums.pragprog.com/forums/64. The forum seems to be more focused on reviewing the book than discussing git issues, however.

Installing and Configuring

I have a Mac Book Pro (Intel) with Snow Leopard. To get MacPorts I went to the site http://www.macports.org/install.php and clicked on Snow Leopard.




Once MacPorts is installed, I issued the command

newtricks:~ ted$ sudo port install git-core +svn +doc

There's a Pragmatic Programmer forum entry that discusses how this macport installation of git did not work, but it worked fine for me. I can tell git is installed and working by checking its version.

newtricks:~ ted$ which git
/opt/local/bin/git
newtricks:~ ted$ git --version
git version 1.6.5.7
newtricks:~ ted$

There are only two required configuration values: user.email and user.name. Here's how you set them; they are silent commands.

git config --global user.name "Ted Kubaska"
git config --global user.email "ted.kubaska@gmail.com"

Although not required, the configuration value color.ui is useful. It color codes various git output. I'll show some examples later.

Display the configuration as follows.

newtricks:~ ted$ git config --global --list
user.name=Ted Kubaska
user.email=ted.kubaska@gmail.com
color.ui=auto
newtricks:~ ted$

Creating a Git Repository

Creating a git repository is pretty easy, in fact trivial. Just make a directory, enter it, and issue a git init. Then you can add files into this repository with git commit. This directory will be the working tree of code you check out from the repository. The repository metadata is in the directory/.git, and, guess what, its contents don't look like CVS.

So I do this ...

newtricks:GitRepo ted$ mkdir tedsrepo
newtricks:GitRepo ted$ cd tedsrepo/
newtricks:tedsrepo ted$ git init
Initialized empty Git repository in /Users/ted/GitRepo/tedsrepo/.git/
newtricks:tedsrepo ted$ ls -a
. .. .git
newtricks:tedsrepo ted$ pwd
/Users/ted/GitRepo/tedsrepo
newtricks:tedsrepo ted$

Then, in that directory, make a file (call it hello.html) to add to the repository.

newtricks:tedsrepo ted$ git add hello.html
newtricks:tedsrepo ted$ git commit -m "Initial checkin for hello.html"
[master (root-commit) f2c49ba] Initial checkin for hello.html
1 files changed, 6 insertions(+), 0 deletions(-)
create mode 100644 hello.html
newtricks:tedsrepo ted$ git log
commit f2c49baf3abafefb03b941db75ae4c026b0c877e
Author: Ted Kubaska <ted.kubaska@gmail.com>
Date: Tue Dec 29 21:07:15 2009 -0800

Initial checkin for hello.html
newtricks:tedsrepo ted$

Make a change in hello.html. Before you can commit the changed file, you must stage it. This is something that seems unique to git. You edit a file, and then you can't just commit it ... you must stage it first.

newtricks:tedsrepo ted$ git status
# On branch master
# Changed but not updated:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: hello.html
#

no changes added to commit (use "git add" and/or "git commit -a")
newtricks:tedsrepo ted$

Notice that a modified, but unstaged file is shown in red. This is a result of that color.ui configuration value.

So stage the file before committing. Stage with git add. Note that the filename becomes green.

newtricks:tedsrepo ted$ git add hello.html
newtricks:tedsrepo ted$ git status
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: hello.html
#
newtricks:tedsrepo ted$

Then, commit.

newtricks:tedsrepo ted$ git commit -m "added head and title"
[master 4b7d2f1] added head and title
1 files changed, 3 insertions(+), 0 deletions(-)
newtricks:tedsrepo ted$

Branches

With CVS, I've always been very careful not to proliferate branches. But I think (from what I've read so far) that branches are key to the way people use git.

The name of the default branch in git (the branch you start with, the mainline, if you will) is called master. Master in Git is what I would call HEAD in CVS.

I thought it was interesting that you can create a branch, checkout the branch, edit a file and commit it to the branch. Then, checkout the master and edit and commit. You now have one version of the file in the branch and another in the master. Now if I rebase the master, the file in master has the changes that were made in the branch as well as the changes made on master. This sounds like a merge to me, although it's not technically a merge because there is a merge command. I suppose I'll see the difference when I start using the merge commands.

Here's what I mean in more detail. The following figure illustrates the actions I'm describing.



Let's say I'm on the master branch of my git repository. I put three lines in that file. I commit the file, then make a branch called R1.0. I edit the file again while still on master (the file now has four lines) and commit it.

Master line 1
Master line 2
Master line 3
Master line 4 <-- this is the line I added on master (not the branch)

Then, I checkout the branch and edit/commit the file.

Master line 1
Release line 1 <-- this is the line I added on the branch (not master)
Master line 2
Master line 3

Then, I checkout the master and rebase master with the branch. My file now has the changes from both the branch and master.

Master line 1
Release line 1
Master line 2
Master line 3
Master line 4

Here's the output I got from the rebase command.

newtricks:tedsrepo ted$ git rebase R1.0
First, rewinding head to replay your work on top of it...
Applying: added 4th master line
Using index info to reconstruct a base tree...
Falling back to patching base and 3-way merge...
Auto-merging hello.txt
newtricks:tedsrepo ted$ git branch -d R1.0
Deleted branch R1.0 (was f3a999b).

As I said, it looks like a merge to me, but I've more to learn.

What is also interesting is that (with the branch checked out), you can tag it. Then, you can checkout master, rebase master with the branch, and actually delete the branch. You can restore the branch by make a new branch from the tag, like ...

newtricks:tedsrepo ted$ git branch R1.0 1.0

where 1.0 is the tag. I made the tag when the branch (called R1.0) was checked out as

newtricks:tedsrepo ted$ git tag 1.0 R1.0



Git
12/31/2009 4:32:37 PM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |   |  Trackback
 Monday, December 28, 2009

So I was able to use adl. This is fun, but really what I want to do is make air files. To do this, I need to use adt (the Air Development Tool), and I need a certificate.

Adt Without a Certificate

If you just use adt without specifying a certificate, you get an intermediate air file. The convention is to give such an intermediate file an airi extension; een if you don't, even if you call it an air file, it's still an intermediate file.

Do a

adt -prepare HelloWorld.air HelloWorld-app.xml HelloWorld.swf

and get



Making My Own Certificate with KeyChain Access

Now I tried making a certificate using my Mac's Keychain Access program. I found that I could not make it in the System Keychain. But I could make it in the login keychain and then move it to the System Keychain. Then, I can export it. I called it TedKubaska002.p12. When I try making an ai file with this certificate, I get an error. The HelloWorld.air file is not created.

newtricks:HelloworldplusCert ted$ adt -package -storetype pkcs12 -keystore TedKubaska002.p12 -tsa none HelloWorld.air HelloWorld-app.xml HelloWorld.swf
password:
Unknown or invalid signature algorithm.
newtricks:HelloworldplusCert ted$

Using the Sample Certificate in the Download

The example code for the TY book I am reading does come with a sample certificate called myCert.p12. I can use that.

newtricks:HelloworldplusCert ted$ adt -package -storetype pkcs12 -keystore myCert.p12 -tsa none HelloWorld.air HelloWorld-app.xml HelloWorld.swf
password:
newtricks:HelloworldplusCert ted$ ls *.air
HelloWorld.air
newtricks:HelloworldplusCert ted$

I get a HelloWorld.air file, and if I click on it in Finder, I get




Click on Install.




Click on Continue.




 

How to Make and Use My Own Self-Signed Certificate

But you know, what I really want is my own self-signed certificate. Here's how I can get that. I removed the HelloWorld.air to ensure that I'm getting a new one.

newtricks:HelloworldplusCert ted$ adt -certificate -cn TedsHome -ou TedsCB -o TedsHome -c US 2048-RSA TedKubaska003.p12 ted128
newtricks:HelloworldplusCert ted$ adt -package -storetype pkcs12 -keystore TedKubaska003.p12 -tsa none HelloWorld.air HelloWorld-app.xml HelloWorld.swf
password:
newtricks:HelloworldplusCert ted$ ls -l *.air
-rw-r--r-- 1 ted staff 404961 Dec 28 11:27 HelloWorld.air

To try our the new HelloWorld.air, first delete the HelloWorld.app that the last example put in /Applications. Then, if I click on the new HelloWorld.air, it acts like before. My self-signed certificate works ... just like the one I got in the example download.

What I find curious is why I couldn't make a working self-signed certificate with Mac's Key Chain application.



Air
12/28/2009 11:54:26 AM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |   |  Trackback
 Sunday, December 27, 2009

OK, I hear so much about Adobe Air., I have to try it out. Air is Adobe's way of letting us build rich desktop applications.

The unfortunate thing about using Air is ... well, the cost. It looks as if you can get the Air runtime and the SDK for free, but Flex Builder 3 costs. And I think you really need Flex Builder 3 to do anything for real.

Flex Builder 3 is an Eclipse plugin, but it's not clear from the Adobe site what versions of Eclipse are supported.




You can get Flex Builder as a standalone (I guess it comes with an integrated eclipse) or as a plugin (but you can't move beyond Eclipse 3.4).

Even worse, Adobe says that Flex Builder does not work on Snow Leopard (http://www.adobe.com/support/OScompatibility.html ) ... or is not tested on Snow Leopard. The web seems contradictory on this point.

Even so, Flex Builder is a deprecated term. The new deal is Flash Builder. I went to this website: http://labs.adobe.com/technologies/.




So I'm going to try and install the beta 2. There's a 60-day time limit on this beta. This is also unfortunate. Flex or Flash Builder is just too expensive for me to use.

Reading This Book

I'm reading Teach Yourself Adobe Air Programming in 24 Hours by Michael Givens. Now I know that the Teach Yourself series gets a lot of bad press on the net ... comments like it takes a lifetime to become a software engineer or how a little knowledge is dangerous or other such pompous comments. It is an unfortunate naming convention ... agreed, you can't learn Adobe Air, Java, C++ or anything else for that matter in 24 hours. But these books are structured as a series of short exercises, each with a clear solution. They take you through installing, configuring, and running simple examples. They're like “get up and running” books, and I like them.

Here's my complaint, though. It's the latest book I could find (2009 copyright), but it still discuses Flex Builder 3, which as much as I can figure out is a defunct name and a defunct version.

Downloads and Installation

You know every time I go to the Adobe site and download something, it seems I often go to a different place.

Here is what I downloaded (Note the dmg extensions ... I'm on a Mac Book Pro with Snow Leopard).

You know you got it installed correctly if you type adl (this stands for Adobe Debug Launcher) and you find it. Like ...

newtricks:Adobe ted$ adl
application descriptor file not specified
usage:
adl ( -runtime <runtime-dir> )? ( -pubid <pubid> )? -nodebug? <app-desc> <root-dir>? ( -- ... )?
adl -help
newtricks:Adobe ted$

Download Flex Builder 3 Trial version from http://www.adobe.com/cfusion/entitlement/index.cfm?e-flex3email It seems you can get this from two places in the Adobe world. Here's another place. http://www.adobe.com/cfusion/entitlement/index.cfm?e=flexbuilder3

I'm in Hour 2 of that Teach Yourself book. It doesn't tell me until Hour 4 that it recommends using Flex Builder. But I think when that time comes, I'll try the Flash Builder beta 2 because of Flex Builder's issue with Snow Leopard.




Examples

You can download a zip with examples for this book from http://www.informit.com/store/product.aspx?isbn=9780672330308

The book also lets you download examples for each hour separately from another site. The examples for Hour 2 are http://www.airination.info/airtraining/tyairin24/Helloworld.zip and http://www.airination.info/airtraining/tyairin24/HelloworldplusCert.zip .

You need the one with a certificate to package the example for distribution (certificates are discussed in Hour 3), but you can run it with adl without a certificate.

I don't think it's right to show the xml and html here. It's not my code. It's easily downloadable form the links I gave.

newtricks:AirApps ted$ adl hello_world-app.xml

Sun Dec 27 15:21:42 newtricks adl[1019] <Error>: The function `CGContextSetFontRenderingMode' is obsolete and will be removed in an upcoming update. Unfortunately, this application, or a library it uses, is using this obsolete function, and is thereby contributing to an overall degradation of system performance. Please use `CGContextSetFontRenderingStyle' instead.



Now that message about the obsolete function. I get that if the <content></content> in hello_world-app.xml contains an html filename (I typed in the html file listed in the book). I don't see that message if the content contains the swf filename that came with the examples download.

newtricks:AirApps ted$ adl HelloWorld-app.xml



Air
12/27/2009 6:14:45 PM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |   |  Trackback
 Thursday, December 24, 2009

Example: Building a Plugin

I've been reading Practical Eclipse Rich Client Platform Projects by Vladimir Silva. I've read the first two chapters and skimmed the rest (there are 10 chapters). The first chapter is called “Foundations of Eclipse RCP,” but it doesn't discuss RCP. There is an introduction to creating a plugin with eclipse, which is certainly something you need to understand before building an RCP application.

The book has a copyright of 2009 (this year barely) but uses Eclipse 3.4. I'm using 3.6M6, and eclipse has changed a bunch, specifically in the way one installs/uninstalls plugins. With 3.5 we started to use the p2 updated sites. Copying a bunch of plugins into your plugins directory is no longer the way.

It's disappointing that a book with a 2009 date is so out of date. I do want to stick with Eclipse 3.6 and figure out how to do these installations and navigate the new UI because 3.6 is where it's at.

Each chapter ends with a hands-on exercise preceded by a discussion of the tools needed for the exercise. Sometimes the tools discussion reads like a group of unrelated facts with code snippet examples. The examples often seem out of context ... yes, there's this xml or this java code, but how does it fit into a working application. The hands-on exercise is supposed to provide that context, but in my opinion seldom succeeds.

Now what I said may sound that I am disappointed in the book, but I'm not. As I've said, I've only read the first two chapters and skimmed the rest. I will read the rest. I want to know how to make a standalone RCP application, but my skimming seems to show how only to run that RCP application from within eclipse. Maybe not, we'll see.

I'm using a Mac Book Pro with Snow Leopard.

The Hands-On from Chapter 1

I struggled with this, but I think my issues were mostly due to me and not the book. I downloaded the source code. Just looking at it was not enough for me. I had to import the project into my workspace. Once I did that, I could build my own identical project.

I'm thankful that this first project is not trivial. It actually does show stuff that I think will turn out to be useful later in the book. Here's a quote that describes what the first exercise is.

... you will write a plug-in to embed a tiny Jetty web server that uses Equinox to define a simple servlet class that returns the headers of the HTTP request.

Sticking Points

Here are some sticking points I had. I'm not faulting the book on these points. When you read the book carefully, these problems are answered. 

  • The project doesn't come with a run configuration. Does it, and I don't know how to see it? I made my own.

When I tried to run this example, I got a permission denied error. I think this is because Jetty wants to start on port 80, but where that is specified I don't know. The way to fix this (and the book has a note on this, but says the note is specific to Linux and does not mention the Mac) is to add the following VM argument to the run configuration: -Dorg.eclipse.equinox.http.jetty.http.port=8080

I did not want to run as root (a bad thing). On the Mac, I don't know how to have eclipse run as root when I run by clicking my icon. I have to become root in a command line and start up eclipse from the command line.

  • I kept running the example as I changed things and got a “port already in use” error. I needed to click on that red Terminate button in the console window before trying again. Yes, this is something I should have known.

  • I didn't understand why I didn't see an osgi prompt in my console window (the prompt is osgi in lowercase). The way to fix not seeing the prompt is to add the Program argument -Console to the run configuration. This is actually mentioned in the book, but it says that Console starts the OSGi console. I was foolish enough to think that the Program argument -consolelog or the default VM argument -Dosgi.noShutdown=true did this. The book says that this VM argument is useful for examining the OSGi framework ... don't you need the osgi prompt for that?

  • I didn't see the output. Wow, guess what ... you have to start up an external browser and point it to http://localhost:8080/servlet. That servlet is the alias which appears under Extension Element Details, and it isn't the default.

  • I wasn't including enough bundles in the run configuration's target platform. I unselected all the bundles under Target platform and then selected only those I had included in the Required Dependencies under the Dependencies tab in the Manifest editor. The correct way to do this is to deselect everything under Target platform, ensure that only the correct workspace is selected and then click the Add Required Bundles button.

    It is beneficial to select the Only show selected bundles checkbox. There are (in my configuration) 375 possible bundles. They don't fit on the screen, and you have to scroll to see what is selected. This method shows that 23 bundles are selected, a lot more than those four that I put into the manifest.

How the Application Looks When It Runs

Here's how the application looks when run. I did an ss at the osgi prompt to display its registered bundles. At this prompt you can start and stop bundles. To stop ch01a_1.0.0, issue stop 27. To start it, issue start 27.

Here's the output from http://localhost:8080/servlet1. Yes, I changed my alias from servlet.




Here's how it looks from within eclipse.




 

How to Configure the Project 

  1. File -> New Project and choose Plug-in Project. I called it ch01a (my imported project from the source download was ch01). Even in Eclipse 3.6M4, you select the Eclipse version 3.5; 3.6 is not in the dropdown because 3.6M4 is still a milestone release.
  2. Click Next. I removed the .qualifier from thePlug-in version, just because it wasn't in the book's figure.
  3. Ensure that “This plug-in will make contributions to the UI” is unchecked.
  4. Click Next. The Manifest editor opens up.
  5. Click on the Dependencies tab and add the plugins: javax.servlet, org.eclipse.equinox.http.jetty, org.eclipse.equinox.http.registry, org.eclipse.equinox.http.registry, and org.eclipse.equinox.http.servlet. Note that the selection window that comes up is blank, but bundles appear when you type in the “Select a Plug-in” box.
  6. Click on the Extensions tab. Add the extension point org.eclipse.equinox.http.registry.servlets. A class name and alias appears on the right under Extension Element Details. Change the alias.
  7. Click on class. In the window that appears, type in javax.servlet.http.HttpServlet for the superclass.
 

The Source Code

I'm not going to show the code. It's not my code. It's available in the source code download from http://www.apress.com. Although the book recommends Apache Log4j, the example uses the Commons Logging service that comes with eclipse.

Good stuff to learn by reading it. There are two java files: Activator.java and Servlet1.java (the book has Servlet.java).

Other References

I found the link http://www.eclipse.org/equinox-portal/tutorials/server-side/ which is helpful. It has a similar but simpler example.

 | Eclipse
12/24/2009 2:58:06 PM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |   |  Trackback
 Wednesday, December 23, 2009

How do Java projects made with Eclipse work outside of Eclipse?

I usually work within Eclipse, but sometimes I get questions like can you run an application built with Eclipse from the command line? And you can. It's pretty straightforward, and I don't know if I'm doing it in the best way. But here is what I did. I have two examples.

First Example: Hello World

The first is just a Hello World. I'm using Eclipse 3.6M4 on the Mac. I made a Java project with File-> New -> Java Project. I called the project com.ted.hello. I made an empty package in the project and then added a class called Hello. Run it as a Java Application from within Eclipse, and it looks like the following. It prints out “hello java” to the console.



 

My workspace is /Users/ted/EclipseProjects/work36M4RCPA. Don't ask why the workspace is called that. I was just trying out some RCP applications earlier and used an existing workspace.

To run this Hello Java program from the command line, go into the directory /Users/ted/EclipseProjects/work36M4RCPA/com.ted.hello/bin. The structure under bin looks like

newtricks:bin ted$ find .
.
./com
./com/ted
./com/ted/hello
./com/ted/hello/Hello.class
newtricks:bin ted$

Run the application as

newtricks:bin ted$ java com.ted.hello.Hello
hello java
newtricks:bin ted$

Second Example: Using Log4j

Yes, I wanted to use Apache Log4j. This lets me address the classpath issue ... like finding the log4j.properties file and the log4j jar. Here's how it looks when run from within Eclipse.




I'm using the 1.2.15 version of log4j, which is the stable version that most people use. You download it in a zip that contains the log4j-1.2.15.jar. The later versions are alpha and beta, and you have to get them from apache's svn repository and build it yourself.

Add log4j-1.2.15.jar to the project's Java Build Path. Right click the project, choose Properties, choose Java Build Path, select the Libraries tab, click the Add External JARs button, and browse to the jar's location. I also had to tell the project how to find log4j.properties. I did this by adding a resource filter. Right click the project, choose Properties, choose Resource Filters, and click the Add button. Select the radio buttons Include and Files. Then, type log4j.properties in the Pattern: textbox.

To run this Logging program from the command line, go into the directory /Users/ted/EclipseProjects/work36M4RCPA/com.ted.log/bin. The structure under bin looks like


newtricks:bin ted$ find .
.
./com
./com/ted
./com/ted/log
./com/ted/log/Logging.class
./log4j.properties
newtricks:bin ted$

I have to set my CLASSPATH variable to point to the log4j.jar and my current directory (which is where the log4j.properties is). Mac has the bash shell so here is the command for that (I originally forgot to export).

newtricks:bin ted$ CLASSPATH=/Users/ted/Downloads/Log4j/apache-log4j-1.2.15/log4j-1.2.15.jar:.
newtricks:bin ted$ export CLASSPATH

newtricks:bin ted$ env |grep CLASS
CLASSPATH=/Users/ted/Downloads/Log4j/apache-log4j-1.2.15/log4j-1.2.15.jar:.

newtricks:bin ted$ pwd
/Users/ted/EclipseProjects/work36M4RCPA/com.ted.log/bin

newtricks:bin ted$ java com.ted.log.Logging
0 [main] INFO com.ted.log.Logging - hello log
write hello
1 [main] INFO com.ted.log.Logging - goodbye log

Summary

So running the Java application form the command line is as you would suspect pretty straightforward. You just have to be in the right directory, use the navigation from your package, and in the case of the second example, set the classpath correctly.


12/23/2009 6:10:57 PM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |   |  Trackback
 Sunday, November 09, 2008
Well, I got this Mac, and I kind of really like it. It's a MacBook Pro with 4 GB of memory.

What did I find that I was unhappy with? It came with Java 1.5, but I was able to get Java 1.6 but not the update I wanted. Mac seems to lag somewhat behind the Java updates.

Now, of course, I'm running Eclipse. What else? When I install ECF the ECF web page tells me to use http://download.eclipse.org/rt/ecf/2.0/3.4/updateSite/site.xml Well, I have to take off the site.xml to get it accepted as an update site.

11/9/2008 10:41:06 PM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |   |  Trackback
 Wednesday, September 03, 2008
Here's a pdf that describes how we did jar signing for the last Eclipse/ECF release. This may not be optimal but it worked for us, and we are looking at ways to improve.

AutoBuild002.pdf (299.54 KB)
9/3/2008 1:32:58 PM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |   |  Trackback
 Monday, July 21, 2008
The Skype provider for Eclipse/ECF Ganymede does not work. It seems a build issue and not a coding issue. We need separate features for Eclipse/ECF on Linux and Eclipse/ECF on Windows. I made an Eclipse/ECF 3.4 Skype on Linux update site. It is available at http://ecf1.osuosl.org/update/2.0Linux/site.xml.

To use Skype with Eclipse Ganymede, first install ECF. Then, go to Help->Software Updates->Available Software->Add Site and put in the above URL for the location.

The following PDF describes how to build this Linux-specific update site.

BuildingSkypeUpdateSite.pdf (1.01 MB)
7/21/2008 6:36:14 PM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |   |  Trackback