Atom Atom feed

New Toys In Java 6: A Follow-Up

I blogged about the New Toys In JDK 6 311 days ago. Many people commented on it. It even prompted a blog entry from David Herron of Sun Microsystems.

Now that Java 6 is released, I finally got a chance to play with some of its new features with the help of the documentation, and to fill out some of the questions marks in my earlier post.

(BTW, the project I'm working on may update its Java version from 1.4 to 5.0. Now someone will have to gather the rationale for going to 6.0. If we start the balling rolling, we may get to use Java 6 starting from 2009.)

Command line tools

Looking into the bin directory, we find the following:

[weiqi@gao]$ diff -q -r /opt/jdk1.6.0.amd64/bin /opt/jdk1.5.0_08.amd64/bin | grep Only | sort
Only in /opt/jdk1.5.0_08.amd64/bin: kinit
Only in /opt/jdk1.5.0_08.amd64/bin: klist
Only in /opt/jdk1.5.0_08.amd64/bin: ktab
Only in /opt/jdk1.6.0.amd64/bin: jhat
Only in /opt/jdk1.6.0.amd64/bin: jrunscript
Only in /opt/jdk1.6.0.amd64/bin: schemagen
Only in /opt/jdk1.6.0.amd64/bin: wsgen
Only in /opt/jdk1.6.0.amd64/bin: wsimport
Only in /opt/jdk1.6.0.amd64/bin: xjc

The command line tools kinit, klist and ktab in Java 5 are not present in Java 6.

Of the six new tools introduced in Java 6, four (schemagen, wsgen, wsimport and xjc) are Java web services tools, which I probably won't have occasion to use in anything beyond toy programs. The other two, jhat and jrunscript are of greater interest to me.

In my earlier post, I also identified jmap and jstack as new in Java 6. They are actually present in Java 5.

Running scripts

The jrunscript tool is a command line script shell. It is capable of running any JSR 223 compliant scripting engine scripts in an interactive (repl) environment. A watered down version of the Mozilla Rhino JavaScript engine is bundled with Java 6. Many JSR 223 engines are available from https://scripting.dev.java.net/.

I have found the word "Engine" a little confusing in this context because the JSR 223 engine for, say, Jython is not the only thing that is required to run Python scripts in Java 6 programs. To run Python scripts from Java 6 programs, you need both the jython.jar file from http://jython.org and the jython-engine.jar from https://scripting.dev.java.net/.

Another gotcha is that jrunscript does not honor CLASSPATH when searching for script engines. After putting the language jars and the engine jars into my CLASSPATH, here's what I get when I try to list the available engines with the -q command line switch (they spelled "implementation" wrong, quickly, somebody file a bug report):

[weiqi@gao]$ jrunscript -q
Language ECMAScript 1.6 implemention "Mozilla Rhino" 1.6 release 2
[weiqi@gao]$ jrunscript -cp $CLASSPATH -q
Language awk Awk as specified in OpenGroup's single UNIX spec. Version 2 implemention "jawk" 0.14
Language ruby 1.8.4 implemention "jruby" 0.9.1
Language BeanShell 2.0b5 implemention "BeanShell Engine" 1.0
Language ECMAScript 1.6 implemention "Mozilla Rhino" 1.6 release 2
Language python 2.1 implemention "jython" 2.1
Language groovy 1.0 implemention "groovy" 1.0-RC-02

To start jrunscript with a different engine from the default JavaScript engine, use the -l command line switch. Here's an interactive awk session:

[weiqi@gao]$ jrunscript -cp $CLASSPATH -l awk
jawk> /^Warning:.*/ { print $0 }
Error: This is an error message.
Warning: This is a warning messag.
Warning: This is a warning messag.
Ctrl-D
java.io.PrintStream@1b52513a
jawk>

Here's an interactive Groovy 1.0 RC 2 session:

[weiqi@gao]$ jrunscript -cp $CLASSPATH -l groovy
groovy> 3.times { println it }
0
1
2
groovy>

As repls go, I have to say jrunscript is a bit anemic. For example, I can't define a multiline function in it. Since most of the JVM based scripting languages comes with their own interactive shells, I'll stick with them, and use jrunscript only to make sure that my JSR 223 scripting engines were installed correctly.

Troubleshooting with jhat

The new in Java 6 jhat tool belong to the troubleshooting tools group. It is a heap dump browser. It is used in conjuction with the other tools in the group, such as jps and jmap that were introduced in Java 5:

[weiqi@gao]$ java Foo & # a trivial swing frame
[1] 15558
[weiqi@gao]$ jps
15558 Foo
15573 Jps
[weiqi@gao]$ jmap -dump:format=b,file=Foo.dump 15558
Dumping heap to /home/weiqi/temp/junk/Foo.dump ...
Heap dump file created
[weiqi@gao]$ jhat Foo.dump
Reading from Foo.dump...
Dump file created Tue Dec 26 21:20:39 CST 2006
Snapshot read, resolving...
Resolving 38538 objects...
Chasing references, expect 7 dots.......
Eliminating duplicate references.......
Snapshot resolved.
Started HTTP server on port 7000
Server is ready.

Now I can browse the heap dump at the URL http://localhost:7000/. Here's the initial screen:

Tags :

Hey, Hasan, I Wrote That!

Hey, Hasan, I wrote that!

Tags :

Ant 1.7.0 Released, Breaks antdtd Task

I downloaded the spanking new Ant 1.7.0 yesterday. And it failed on the first build.xml I tried it on.

I have many little build.xml snippets in my ~/temp/src/ant directory. The antdtd has is the first one listed. When I ran it, Ant 1.7.0 complained that a certain class related to the ftp task is not present and aborted. I haven't checked the mailing list archives or the documentation yet, so I don't know the full story.

I have switched back to Ant 1.6.5 for the moment as it looks like switching to Ant 1.7.0 is not going to be a trivial task.

Tags :

Groovy 1.0 By The End Of 2006? Only Ten Days Left!

(Via Javalobby.)

Jay Zimmerman, in a eWeek story: Jochen will be able to focus his efforts exclusively on Groovy development now, which will help ensure that Groovy 1.0 is released by the end of 2006 and future enhancements in Groovy will be addressed at an accelerated rate.

Also from the article:

Darryl K. Taft, writing for eWeek: Big Sky Technology is putting its marketing muscle behind the open-source, Java-based Groovy language to take the project to a 1.0 version and beyond to ubiquity.

Jay Zimmerman, president of Denver-based Big Sky, said the company is funding the development of Groovy and has secured the services of Jochen Theodorou, the chief Groovy contributor. Big Sky is the company behind the No Fluff Just Stuff Java symposium series.

Who are they?

Tags :

I Got My Rebate Money Back

I'll make this short:

  • I bought a HP Pavilion laptop from Office Depot in July 2006, when they advertised it at $499 after rebates.
  • I send out the three rebate forms (two to HP, one to Office Depot) the day I got the machine.
  • By mid November, I have not received my rebate check from Office Depot.
  • I went into the store, and asked someone there, who showed me a website where I can just type in my name to see how my rebate is doing. It showed that the rebate has just been mailed the day before.
  • However, I received the check only two weeks ago in early December.

Not knowing how the rebate industry worked, I cannot draw any conclusions. But somehow I have a feeling that had I not checked, I would never have gotten my money back.

Tags :

Justin Michel Blogger

My fellow OCI programmer Justin Michel started blogging a while back. And he's full of interesting ideas. Here's the link:

Various Technical Topics

Justin is probably best known to the outside world as the designer and one of the implementors of the open source "Makefile, Project file Creator (MPC)," which is used the world over in ACE and TAO based C++ development projects, even some non-TAO based projects.

It was precisely after working on a project where MPC is used that I wrote this blog entry 197 days ago.

However, my message can't seem to go across to the general Java public without me sitting down with somebody and explaining exactly what it is that I want. Maven's ability to generate Eclipse and IntelliJ IDEA project files comes very close to my ideal. However I hate Maven's XML file format. Plus I haven't gotten past the error messages (some artifacts or other are not available, would you please read a clueless website to figure it out!) when I ran just "mvn" in an empty directory after a fresh Maven 2.0.4 install.

Tags :

A Groovy Resurgence? It Looks Like It.

ST. LOUIS, Dec. 14 — Remember Groovy, the Ruby like language designed for the JVM and only for the JVM? (I first blogged about it 1042 days ago, and then some. Oh boy that was a long time ago.)

According to Jeff Brown, a principal software engineer at OCI, Groovy is about to have a resurgence in the next few months.

Brown made the remark at the monthly meeting of the St. Louis Java Users Group, which meets on the second Thursday of each month at 6:30pm in the auditorium of One City Place. He gave a demo-rich presentation on the Groovy programming language version 1.0 RC1 to an engaged audience.

Among the signs given by Brown, who is a core team member of the Grails open-source web applications framework project now, as evidence of the Groovy resurgency are:

From where I stand, it does seem that groovy is in a resurgence, which is part of the scripting/dynamic language resurgence that is happening on the JVM.

Get the slides of the talk from here.

Tags :

Getting Files Around: Secure Copy (scp)

A question come up today about the best way to get files around between a Mac OS X box and a Fedora Core 6 box:

Me: Definitely scp.
Him: But I'm not a Unix person.
Me: It's just like cp, only better.
Him: I'll look it up. (Typed "man scp" in a terminal bash prompt on the N" MacBook Pro laptop, but the machine is pegged and nothing would show up.)

Before I started using scp, I used ftp to move files between my machines. It does what needs to be done, and I was content in using it. Then one day someone (I think it's Jonathan) said "I've put the package on the CVS server. You can use scp to get it." That's my first encounter with scp. Actually it was PSCP because I was using PuTTY on a Windows box at the time.

I did the Googling, and manning, and printing and reading, and finally figured it out. It's non-trivial, the setting up of ssh is, the hard part being the generation (and the safe-keeping) of the key pairs. However, once that is done, the rest is easy. To do the actual work, the target machine needs to have a running sshd daemon. And on both Mac OS X and Fedora Core 6 Linux it is fairly easy to turn on sshd.

Now, scp. Scp stands for "secure cp" where cp is short for "copy." So scp allows you to securely copy files around.

In the following low-tech screencast (you have to imagine me typing the commands in and getting the responses that followed), I created a file "dummy.txt" and copied the file three times, once locally on gao-2006 (My Fedora Core 5 workstation), once local-to-remote to gao-2005 (my Mac mini), and once remote-to-remote from gao-2005 to gao-2002 (my web server, a.k.a. www.weiqigao.com):

[weiqi@gao-2006 ~]$ mkdir scp-demo
[weiqi@gao-2006 ~]$ cd scp-demo/
[weiqi@gao-2006 scp-demo]$ echo This is a test. > dummy.txt
[weiqi@gao-2006 scp-demo]$ ls
dummy.txt
[weiqi@gao-2006 scp-demo]$ scp dummy.txt copy_of_dummy.txt
[weiqi@gao-2006 scp-demo]$ ls
copy_of_dummy.txt  dummy.txt
[weiqi@gao-2006 scp-demo]$ scp dummy.txt gao-2005:/Users/weiqi/copy_of_dummy.txt
dummy.txt                                     100%   16     0.0KB/s   00:00
[weiqi@gao-2006 scp-demo]$ ssh gao-2005 ls copy_of_dummy.txt
copy_of_dummy.txt
[weiqi@gao-2006 scp-demo]$ scp gao-2005:/Users/weiqi/copy_of_dummy.txt \
gao-2002:/home/weiqi/copy_of_copy_of_dummy.txt
copy_of_dummy.txt                             100%   16    85.8KB/s   00:00
Connection to gao-2005 closed.
[weiqi@gao-2006 scp-demo]$ ssh gao-2002 ls copy_of_copy_of_dummy.txt
copy_of_copy_of_dummy.txt
[weiqi@gao-2006 scp-demo]$

Notice that when copying file locally, scp is just like the regular cp on Unix/Linux or copy on Windows. Once you understood that, copying files remotely is easy to comprehend: you just have to use the "host:/absolute/path/to/file" format to address the remote file. Note also that both arguments can be remote files.

It just so happened that I have accounts set up on these machines that bear the same login "weiqi". Had the logins been different on different machines, I would need to use the "login@host:/absolute/path/to/file" format to address the remote file.

Had I not had ssh-agent running and my private key cached by it, scp would have prompted me for the passphrase of my key store.

Tags :

Java 6 Is Here

It's four days later then the December 7, 2006 promised date I reported 34 days ago, but InfoQ is reporting that Java 6 is available for download.

However, Sun's Java page, as of this writing, still has a "Download the Java SE 6 Release Candidate" prominently displayed, which leads you to the "Java SE Early Access Downloads" page that featured "JDK 7".

Hopefully by the time you read this everything will be fixed. (The website is fixed.)

Tags :

Follow-ups: InfoQ, Celtix, AMQP, Durability of Pizza

I chatted with David and Brian this afternoon. And I mentioned something that good marketers do all the time: They have the ability to speak enthusiastically about their product, repeated thousands of times. And every time, they speak as if its the first time. Ordinary people, on the other hand, don't tend to repeat what they thought they already said, thinking, "I've said that a month ago, they should have know it by now."

The truth is that people won't remember it. And you have to say something again and again to get people to absorb it. And in that spirit, I'll follow up on a few of my past posts.


2006/07/17: InfoQ---Technical Articles That Make Sense

The post was made about six weeks after InfoQ's launch. I said I'll make it part of my Firefox home pages. I did indeed. And I'm happy to say that I'm not disappointed. Here's my repeated recommendation:


2006/05/26: Celtix 1.0: First Impression

2006/06/20: A Messaging Standard Burst Onto The Scene

Celtix is a ObjectWeb hosted open source non-ESB ESB project sponsored by IONA which is later fused with XFire from Codehaus to become the Apache incubator project CXF.

AMQP is a on-the-wire queue-based messaging protocol/model specification backed by a few companies, including Red Hat, 29West and IONA.

The two seemingly unrelated story converged into one, when IONA announced the availability of their new open source product Celtix Enterprise ESB five days ago. It includes multiple Apache (including incubator) and other open source projects such as CXF, ActiveMQ, Eclipse SOA Tools. It also includes Qpid, an Apache incubator project that implements the AMQP specification.

For some reason, the press release was not very clear about the actual licensing terms. I have to prod a little on InfoQ's news item about it, and download and install the product, to get a fuller picture. It's basically Apache License 2.0. IONA will offer consulting, training and support (subscriptions) for the open source product.

Talking about IONA, there is a Steve Vinoski interview on Software Radio.


2006/03/27: A Science Experiment Commences

2006/04/27: The Durability of Pizza

Well, I did not actually write these entries at the time, but I should have.

What happened was this. We ordered Indian food for an OCI internal event. The food arrived a few hours early, and we debated whether we should put the food (fresh out of the kitchen hot) into the refrigerator. Jonathan said yes, and I said no. Somehow or rather the topic shifted to "How long will a piece of pizza last?"

It just so happened that the next day, we had a OCI internal Java (or C++) lunch and had some leftover pizza. I took a piece (Papa John's Pepperoni), put it in a paper plate, wrote "Science Experiment, Starting Date: 2006/03/27" on the plate, and placed it in a corner of my desk. I told everyone, "It will last at least a month." Others were skeptical.

Imagine the fun we had during that month.

Oops, it's late and I've got to go to bed. I'll tell you about the dramatic conclusion of the experiment some other time. (Or leave a comment with your speculative conclusion.)

You Won't Believe This, But The Arrow Operator Is Coming To Java 7

And it means something completely different

Yes, the -> operator. According to Danny Coward, Sun Java SE Platform Lead, Java 7 will use the arrow operator for Java Beans property access:

Danny Coward talk PDF (p.27): Reading JavaBeans properties
a.setFoo(b.getFoo());
a->Foo = b->Foo;

What's wrong with using the good old dot?

Most of the stuff mentioned are nice and useful. I like the XML literal and the BigDecimal arithmetic operator overloading. The Swing simplification effort is long over due too.

Tags :

Website Statistics

The topic drifted to website traffics in a meeting I'm in today, and I mentioned that according to my blog's log summary page, I've had more than one million hits so far this year. Well, according to the Fedora Core 3 built-in website statistics page, my website (the four static pages, some articles and the weblog) has reached just a little over two million hits, and 46 GB's worth of stuff has been downloaded. That's pretty amazing.

Summary by Month
Month Daily Avg Monthly Totals
Hits Files Pages Visits Sites KBytes Visits Pages Files Hits
Dec 2006 4599 3896 1877 673 3574 676918 4039 11264 23378 27595
Nov 2006 6375 5320 2826 803 17500 4821436 24099 84799 159605 191265
Oct 2006 5487 4655 2092 759 14302 4700352 23558 64876 144323 170124
Sep 2006 5542 4745 2073 749 11582 4371190 22494 62201 142374 166269
Aug 2006 6640 5676 2643 808 16082 5764646 25061 81933 175969 205869
Jul 2006 6002 4573 2448 704 10500 4769150 21848 75902 141770 186073
Jun 2006 6132 4707 2101 745 11355 4575609 22368 63058 141238 183972
May 2006 7487 5989 3030 817 12432 4827193 25344 93953 185670 232114
Apr 2006 6173 4966 2659 761 11583 3718537 22849 79796 149002 185195
Mar 2006 7385 5456 2781 1036 12168 4287865 32122 86223 169154 228939
Feb 2006 4918 3979 1695 808 11099 1803092 22631 47487 111424 137715
Jan 2006 4698 3696 1684 700 10342 1741197 21724 52225 114589 145640
Totals 46057185 268137 803717 1658496 2060770
Tags :

Microsoft Word Users - Security Alert

(Received this from our sysadmin. Thought I'd pass it along.)

My Sysadmin: A new Word exploit has been announced. Please don't open Word documents from unknown sources, or unexpected Word documents from a known source.

OpenOffice users are safe.

Tags :

Transcript Available: Java Script Talk

Thanks Kyle!

Wow! Kyle Cordes, who presented at the November meeting at the St. Louis JUG on Java Scripting, has made an audio recording (see his blog entry) of the talk as well as a transcript available on his website.

Fortunes

I went out to House of Wong for lunch with the OCI crowd. And here's the fortunes Paul and I got from our respective fortune cookies:

Paul's Fortune: Good luck is coming your way.

My Fortune: Be patient. Good things come to those who wait.

I guess I'll just have to wait till tomorrow.

Tags :