While debugging another manifestation of the "wrong library for groovy webtest" bug recently, I found an email thread that makes reference the java_home command (sadly, I can't find an online manual page to link to) to cleanly select a specific version of the JVM under OS X. Here I thought manually pawing through /System/Library/Frameworks to look for versions to set JAVA_HOME to was the "right" way to do it. Learn something new every day.
enjoy,
Charles.
Showing posts with label java. Show all posts
Showing posts with label java. Show all posts
Monday, July 13, 2009
Thursday, January 22, 2009
Jython talk at SJUG
Here are the slides of a talk I gave last February at the Salem Java Users Group - SJUG. Although it looks like it's primarily about Python and Jython, my bigger emphasis was on extension programming - scripting existing Java code. In other words, a form of polyglot programming.
Enjoy,
Charles.
Enjoy,
Charles.
Wednesday, January 21, 2009
Book: Java Power Tools
Java Power Tools by John Ferguson Smart
ISBN: 978-0-596-52793-8
Java Power Tools provides a fairly detailed introduction to a number of tools for Java programmers. It fits nicely between the O'Reilly Hacks series and having a dozen books like Ant: The Definitive Guide, 2nd Edition. Like the Hacks books, Java Power Tools provides an introduction to a bunch of tools. The Hacks books are great for answering the question "I've heard of that tool, but where does it fit?" But whereas the Hacks books provide just an appetizer, this book provides a main course, enough to get seriously started with the tool being discussed. And then, if you want all the gory details, a Definitive Guide could provide the full five-course meal.
The selection of tools presented was really good, at least for me. For example, I know about continuous integrations servers, but I haven't set one up. At one client site, they were using Hudson, which I had some exposure to, but didn't know much about the others like Cruise Control, Continuum, and LuntBuild. Similarly, I've been using JUnit 3.x for years, but I didn't really know what was different in JUnit 4 or how that compares to TestNG. This book provided me with a great overview of these and other tools. Java Power Tools provides a great way to get up to speed with a general area of tooling (e.g., continuous integration servers) or a good cross-section of the majority of the Java tools in use today.
If I had to pick something to complain about, it would be Part II - Version Control Tools. These aren't really Java tools, although every programmer (Java or otherwise) should be using them. Or given the decision to include version control tools, I'd suggest excluding CVS because it's old and including at least one distributed version control tool like Mercurial (used by the Open JDK project and NetBeans) or git (used by the Linux kernel).
So, in conclusion, unless you have no free will about tool selection or you already know all of these tools backwards and forwards, I highly recommend this book to almost any Java programmer.
enjoy,
Charles.
ISBN: 978-0-596-52793-8
Java Power Tools provides a fairly detailed introduction to a number of tools for Java programmers. It fits nicely between the O'Reilly Hacks series and having a dozen books like Ant: The Definitive Guide, 2nd Edition. Like the Hacks books, Java Power Tools provides an introduction to a bunch of tools. The Hacks books are great for answering the question "I've heard of that tool, but where does it fit?" But whereas the Hacks books provide just an appetizer, this book provides a main course, enough to get seriously started with the tool being discussed. And then, if you want all the gory details, a Definitive Guide could provide the full five-course meal.
The selection of tools presented was really good, at least for me. For example, I know about continuous integrations servers, but I haven't set one up. At one client site, they were using Hudson, which I had some exposure to, but didn't know much about the others like Cruise Control, Continuum, and LuntBuild. Similarly, I've been using JUnit 3.x for years, but I didn't really know what was different in JUnit 4 or how that compares to TestNG. This book provided me with a great overview of these and other tools. Java Power Tools provides a great way to get up to speed with a general area of tooling (e.g., continuous integration servers) or a good cross-section of the majority of the Java tools in use today.
If I had to pick something to complain about, it would be Part II - Version Control Tools. These aren't really Java tools, although every programmer (Java or otherwise) should be using them. Or given the decision to include version control tools, I'd suggest excluding CVS because it's old and including at least one distributed version control tool like Mercurial (used by the Open JDK project and NetBeans) or git (used by the Linux kernel).
So, in conclusion, unless you have no free will about tool selection or you already know all of these tools backwards and forwards, I highly recommend this book to almost any Java programmer.
enjoy,
Charles.
Wednesday, January 07, 2009
Groovy at SJUG
On January 6th, I spoke at the Salem Java Users Group on Groovy. The premise was not to replace Java, but rather to show how it can be used in addition to Java. Here are the slides.
Enjoy,
Charles.
Enjoy,
Charles.
Thursday, August 28, 2008
Ant, JavaDoc, and CreateProcess error=87
I've been developing an Ant build file for a large-ish base of existing code. I've been using my Mac as the primary devleopment platform, but the ultimate target (for the other developers) is Windows. My task to build the javadocs runs fine on OS X, but the first time I rant it on Windows, I got the following:
c:\demo\build.xml:180: Javadoc failed: java.io.IOException: Cannot run program "c:\Program Files\Java\jdk1.6.0\bin\javadoc.exe": CreateProcess error=87, The parameter is incorrect
After about 10 minutes of Googling, I found a/the simple solution: add the useexternalfile attribute to the javadoc task in Ant. Voila , back in business, on the PC at least, and it didn't seem to break the build on the Mac.
Charles.
c:\demo\build.xml:180: Javadoc failed: java.io.IOException: Cannot run program "c:\Program Files\Java\jdk1.6.0\bin\javadoc.exe": CreateProcess error=87, The parameter is incorrect
After about 10 minutes of Googling, I found a/the simple solution: add the useexternalfile attribute to the javadoc task in Ant. Voila , back in business, on the PC at least, and it didn't seem to break the build on the Mac.
Charles.
Sunday, July 06, 2008
Book: Effective Java
Effective Java, 2nd Edition
by Joshua Bloch. ISBN 0321356683
This is the best book that I've read that I didn't know I needed to read. If you are a pretty good Java programmer, and you want to be better, this is a book you should definitely read.
Back in the day (BITD), we had Scott Meyer's book Effective C++
, and we needed it. Even without templates and all the "new" things in C++, C++ was a large and complex language. I loved Effective C++ not only because it had lots of tips to keep you out of trouble when coding C++, but also because the organization was brilliant: each tip was about the right length to be read while sitting on the can.
I ignored the first edition of Effective Java book when it came out because I smugly assumed that Java was so superior to C++ (Java is C++ with the pointy bits filed down) that it wasn't really necessary. And that may or may not have been true in the 1.0 or 1.1 days of Java, but with the release of Java 5, the language has certainly grown and is now sufficiently complex that a book like this is a necessity, especially if you've recently moved up to Java 5 or Java 6. Lucky for me, this book landed on my desk against my will.
The book uses that same sitting-on-the-can format from Effective C++; the information is broken down into nice, small bits of information that you can read one or two at a time. These are grouped into 10 sections. There are specific sections for Java 5 features like Generics and Enumerations, which is great for people like me who were stuck on 1.4 for far too long.
What is really amazing about this book is that I learned a lot about topics that I thought I already knew about. For example, I've used serialization in a number of formats (built-in and do-it-yourself) for years, but I realized there's a lot more that I had no idea about. I will certainly think twice before doing any serialization in the future.
Unless you're the sort that knows the Java Language Specification
by heart, you need to read this book.
Enjoy,
Charles.
This is the best book that I've read that I didn't know I needed to read. If you are a pretty good Java programmer, and you want to be better, this is a book you should definitely read.
Back in the day (BITD), we had Scott Meyer's book Effective C++
I ignored the first edition of Effective Java book when it came out because I smugly assumed that Java was so superior to C++ (Java is C++ with the pointy bits filed down) that it wasn't really necessary. And that may or may not have been true in the 1.0 or 1.1 days of Java, but with the release of Java 5, the language has certainly grown and is now sufficiently complex that a book like this is a necessity, especially if you've recently moved up to Java 5 or Java 6. Lucky for me, this book landed on my desk against my will.
The book uses that same sitting-on-the-can format from Effective C++; the information is broken down into nice, small bits of information that you can read one or two at a time. These are grouped into 10 sections. There are specific sections for Java 5 features like Generics and Enumerations, which is great for people like me who were stuck on 1.4 for far too long.
What is really amazing about this book is that I learned a lot about topics that I thought I already knew about. For example, I've used serialization in a number of formats (built-in and do-it-yourself) for years, but I realized there's a lot more that I had no idea about. I will certainly think twice before doing any serialization in the future.
Unless you're the sort that knows the Java Language Specification
Enjoy,
Charles.
Friday, May 16, 2008
@Override is your friend
When Java 5 came out, I had my head down teaching and wasn't really paying attention. I've since started working with it and have been using annotations for "big" tasks like Hibernate/JPA metadata. I was pretty underwhelmed by @Override - one of the only stock annotations. When I implement toString, I know I'm overriding the method on Object. Who cares?
The other day I was beating my head into the desk trying to figure out why a Swing table wasn't editable. I had overridden the isCellEditable method on JTable, but the cells weren't editable. Then, I remembered something from the annoations tutorial I'd read at some point: "While it's not required ... it helps to prevent errors." So, I added @Override, and sure enough - I'd misspelled the method name, just the sort of error that @Override can prevent.
I've got the religion. And like any recent convert, I suggest you get it too.
enjoy,
Charles.
The other day I was beating my head into the desk trying to figure out why a Swing table wasn't editable. I had overridden the isCellEditable method on JTable, but the cells weren't editable. Then, I remembered something from the annoations tutorial I'd read at some point: "While it's not required ... it helps to prevent errors." So, I added @Override, and sure enough - I'd misspelled the method name, just the sort of error that @Override can prevent.
I've got the religion. And like any recent convert, I suggest you get it too.
enjoy,
Charles.
Monday, May 12, 2008
Data Driven, my eye!
I've started using the WebTest web testing framework. Mostly, it's pretty cool. However, I have a bone to pick with screencast demonstrating the dataDriven task.
Charles - aka Cranky Pants.
Update:
OK, so it sucked to be me, but not any more. I figured out my various issues with the dataDriven task. It turns out that the screencast (clearly) shows them developing in the tests directory of a WebTest project. I missed that and tried to use dataDriven in the top-level build.xml in a target that didn't declare wt.defineTasks as a dependency. Guess what wt.defineTask does - yup, it does the taskdef.
I coupled that breakthrough with breaking down and using Excel to create the xls file (instead of exporting from Google) and viola - I'm livin' large and no longer cranky.
enjoy,
Charles.
P.S. Apologies to Cheech and Chong.
- There's a "slide" that says "Do you know the dataDriven Ant task?" I know of no such standard Ant task. It turns out that it's specific to WebTest. Not really clear.
- They show no configuration steps to use it, implying that it works out-of-the-box. I don't know if my environment is wacked (I installed from the developer build, as they suggested), but I had to add an Ant taskdef referring to com.canoo.ant.task.PropertyTableTask, and I only found that by looking in the source.
- The screencast shows running ant at the command line, which is how I've been running my tests, but I had to run their webtest script instead. Again, maybe my installation is wacked.
- I really wish it could handle data in a TSV/CSV/text file, since I don't have Excel installed on the machine where I'm running these tests, but it only seems to accept an xls file.
- Just to add insult to injury, Google Spreadsheet (which I'm using to generate the data file) seems to append a bunch of empty lines to my spreadsheet, which causes the dataDriven task to repeat the last line 90-odd times.
Charles - aka Cranky Pants.
Update:
OK, so it sucked to be me, but not any more. I figured out my various issues with the dataDriven task. It turns out that the screencast (clearly) shows them developing in the tests directory of a WebTest project. I missed that and tried to use dataDriven in the top-level build.xml in a target that didn't declare wt.defineTasks as a dependency. Guess what wt.defineTask does - yup, it does the taskdef.
I coupled that breakthrough with breaking down and using Excel to create the xls file (instead of exporting from Google) and viola - I'm livin' large and no longer cranky.
enjoy,
Charles.
P.S. Apologies to Cheech and Chong.
Saturday, March 29, 2008
Netbeans is a memory hog?
I was looking at Activity Monitor on my iMac, and I couldn't read the size entry for the Netbeans process that was running. So, I selected it and got a detail report:
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5S1El6DnbjMqxft1fcPvvsy7G7TlT44jDXT2XHhNSBK71ht0xQG6g329WvxYj7R3B5bW_KKXDnpH6bM8qAt13xR-zh3ysponLxiwbC-RkVxKOCTnh4Smlm4QVAHhewsMEpvWZYQ/s320/nb-hog.png)
I knew that Java and Netbeans could be memory hogs, but 16 million TB (16 exabytes) is a bit much. Good thing I have virtual memory! (I didn't alter the image, but clearly it's a bug with Activity Monitor and/or OS X 10.5.2.)
Charles.
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5S1El6DnbjMqxft1fcPvvsy7G7TlT44jDXT2XHhNSBK71ht0xQG6g329WvxYj7R3B5bW_KKXDnpH6bM8qAt13xR-zh3ysponLxiwbC-RkVxKOCTnh4Smlm4QVAHhewsMEpvWZYQ/s320/nb-hog.png)
I knew that Java and Netbeans could be memory hogs, but 16 million TB (16 exabytes) is a bit much. Good thing I have virtual memory! (I didn't alter the image, but clearly it's a bug with Activity Monitor and/or OS X 10.5.2.)
Charles.
Subscribe to:
Posts (Atom)