Jean-Christophe Collet's Weblog
Jean-Christophe Collet's Weblog

20070327 Tuesday March 27, 2007

Spring cleaning and FTP

With OpenJDK upon us I figured it's about time I dusted my blog and start posting again since I intend for it to be one of the sources of information and discussion concerning the evolution of the networking stack (more on that later).

Anyway, since it's a question that comes up quite often these days, it occurred to me that the state of FTP support in J2SE would be a good subject for jump starting my writing efforts. So, without further ado:

FTP support in J2SE

Let's get something out of the way first: Yes I'm fully (dare I say painfully) aware that the current FTP API is somewhat lacking, to say the least. There is an RFE filed against it, 4650689 to be exact . It has rather high vote count (119 last time I checked and is on the top 25 RFEs), and, believe me, it hasn't gone unnoticed. I have been pushing for that RFE for a long time now and I have hopes that it will finally get approved soon. When that happens (fingers crossed) I'll post here the details of what we intend to do. And I'd like to personally thank all and everyone of you who voted for it and/or posted comments. It does help. A lot. So thanks again.

Meanwhile, let's have a look at we already have.

FTP is one of the protocol handlers mandated for the URL API. Which means that, for the time being, the only public FTP API in J2SE is through the URL and URLConnection API. In short, it means that to access a file on an FTP server you create a URL as specified in RFC 1738, get a URLConnection out of it, then use getInputStream() or getOutputStream() to get or put, respectively, the document. Did I say 'put'? Yep, I sure did! How many of you did know that you can do puts as well as gets? <counting...> Really, that many? I'm surprised. So, how many now knew that you can also provide a user name and password? An absolute file path? Or a type (binary for instance) of transfer?

Yes you can do all that. Let's look at a quick example:

URL url = new URL(“ftp://user:password@host.dom/%2Fetc/motd;type=a”);
URLConnection conn = url.openConnection();
PrintWriter out = new PrintWriter(conn.getOutputStream());
out.println(“Message of the day”);
out.close();

And voila! You just logged to an FTP server using a user name and password, then wrote to the /etc/motd file by doing a PUT in ASCII mode.

The important things to notice here are:

  • Calling getOutputStream() instead of getInputStream() will trigger a PUT operation instead of a GET.

  • If you need to authenticate when logging onto the server, prefix the hostname with user:password@

  • If you need to use an absolute path use %2F (code for a slash) at the start of the file path.

  • If you need to specify a type of transfer (default is binary) add ';type=<a,i,d>' at the end of the URL. 'a' means ASCII, 'i' Image (or binary) and 'd' means directory.

I'd like to add that the FTP protocol handler will also automatically try to use passive mode when possible, knows about IPv6 extensions and will, if the URL points to a directory, give you a listing of its content.

So, I hope you can see now that you can do many FTP operations through the URL API.

Like I said earlier, I know that many features are missing, like being able to do more than one operation per session, or rename a file, or use FTP over SSL and so on and so forth. But hopefully, not for much longer.

(2007-03-27 06:02:08.0) Permalink

20040721 Wednesday July 21, 2004

There is no place like ::1

If you got that joke then you're part of a small club: the few (for now) who can read IPv6 addresses in literal form.

Yes, IPv6 again! Why do I come back to that topic? Because yesterday (July 20th 2004) ICANN officially announced support for IPv6 in their root servers.

What the hell does that mean, do you ask? It means that DNS, the mechanism that translates internet names like www.sun.com into IP addresses, can now return IPv6 addresses as well! The first 3 countries (or subdomains) to follow suite are Japan (.jp), Korea (.kr) and France (.fr).

Things are really moving fast on that front. After the Department of Defense mandate (see my blog entry dated June 28th) this is a very important step towards the large scale adoption.

What we need now is Linksys & Netgear providing IPv6 with 6to4 tunneling in their routers and we're all set!


P.S.: ::1 is the IPv6 equivalent for 127.0.0.1, the loopback address, also known as localhost or ... home.

(2004-07-21 08:44:50.0) Permalink

20040713 Tuesday July 13, 2004

Firefox & Thunderbird: my setup

Another technical entry, but this time not Java related.

For quite a long time (years really) I have been using Mozilla a my main browser and mailer. About a year ago, I think, I switched to Firefox (aka Pheonix, aka Firebird) the standalone browser and Thunderbird, the standalone mailer. Both are from the Mozilla Foundation, so they inherited from the years of development and debugging that were put into the Mozilla suite. Why did I switch? Mostly because I wanted something a bit lighter, because I liked the look and feel better and also because I wanted to support an initiative that I thought was worthwhile (meaning: I thought it would be fun).

Besides all the security and privacy advantages, which are getting a lot of publicity these days, I like the extension mechanism and I wanted to share with you the few I use:

  • Firefox Extensions:
    • AdBlock: This one is a must. I just can't live without it anymore. It let you filters out advertisements and other nasties (like web bugs, and other tracking meachanisms) based on pattern matching. A real life safer.
    • SwitchProxy: If like me you change your proxy on a regular basis (happens a lot on a laptop, or when switching between VPNs), this is a very useful toolbar. It let you pick a proxy setting from a drop-down menu. Very neat.
    • Dictionnary Search: Another must. Select a word, right-click to get the context menu and launch a dictionary search in a separate tab, and yes, you can configure which online dictionary to use. Very useful when blogging!
    • Noia 2.0 Extreme: Not an extension, but the theme I use. Very nice. On top of that, it does exist for Thunderbird (see below), so I have a unified look and feel for both apps.
  • Thunderbird extensions:
    • Contact Sidebar: List your contacts from your address book in the sidebar, below your folders. Pretty neat.
    • Free Desktop Integration: Another must if you're using Linux or Solaris. What this extension does is use the notification area in the Gnome (or KDE) toolbar to let you know when a new mail arrived. That way your mailer can be iconified and you still get a visual notification. The Linux binary is available on the page, I had to port the sources to Solaris (Solaris 10 with Gnome 2.6 to be exact), but it works fine.
    • EnigMail: A very powerful extension that let you encrypt and decrypt your mail with PGP or GnuPG.
    • Noia 2.0: Again, not an extension but a very nice theme. See above.

That's it for now. Don't hesitate to let me know what your favorite extension is (yes, I know about mouse gestures, I just don't like them that much).

(2004-07-13 06:24:35.0) Permalink

20040711 Sunday July 11, 2004

java.net API & proxies

I got some interesting feedback from my last entry, and I may post an update, but I'd rather sleep on it a few more days, at least. Thanks to all those who took the time to comment. I appreciate it.

It is my intent to have technical entries in my blog, not just rants or movie reviews. So I figure it's about time I get to it. One thing that bugs me is how badly documented the Java Networking API is. A lot of the bug reports, or requests for new features, we are getting prove that. Many times the answer is "You can already do that using this API" or "This is not a bug, it is supposed to do that". Of course we, the Networking Team, are to blame for that, but as all developers know, documentation is hard to do and very time consuming. The good news is that we've taken steps to remedy that situation. In particular you'll see that, in J2SE 5.0, we've improved the javadoc entries quite a bit. But we're also working on some other means, like white papers and articles that, hopefuly, will end up on the web site.

And that's precisely what I want to discuss here, I have written such a white paper, on proxy management in the Java networking API and I'd like you to review my most recent draft and let me know what you think of it, particularly whether it's clear or complete enough.

Here is a quick overview of its content:

  • System Properties: We first discuss all the system properties related to proxy settings, there a quite a lot of them, and how they affect each other.
  • New APIs in 1.5.0:
    • java.net.Proxy class: We present the newly introduced Proxy class and how to use it in new methods for Socket and URLConnection
    • java.net.ProxySelector: We go deep into the new mechanism to let applications dynamically assign proxies to the different protocols. The class is described, and using a practical example, we do show how to implement such a selector.

So, if you are interested you can get the PDF file, read it and, I hope, send me feedback, either through this blog or directly via Email.

Also, there are two other subjects I'd like to solicit feedback: What part of the java networking API would like to see described next? (some possible candidates are: Cookie management, IPv6 support, timeouts, etc.). And, what is the networking feature/bug that you think should be implemented/fixed in the next release, and why is it so important to you?

Thanks in advance. (2004-07-11 07:49:33.0) Permalink

20040708 Thursday July 08, 2004

Sun and OpenSource: Old but estranged friends?

Something that really ticks me off lately is the whole "Sun vs OpenSource community" thing!

Really, it's ridiculous! It's like watching two very old friends having bitter arguments, while forgetting how much they owe each other, and how much they need each other. Both party are guilty here, if you ask me (and if you didn't ask, or don't care,then stop reading now).

Let's start with full disclosure: I have been involved with the Open Source Community long before it was even called that, back when it was still called "Free Software". Heck, I was one of the main contributors to one of the most notorious, and most enduring (17 years and counting), project. I also co-founded a small not-for-profit organization dedicated to Free Software, which later, much later, became the French branch of the Free Software Foundation. Although I have to admit, my participation was minimal, specially compared to the main guy behind it, Loic Dachary (Hi Loic, how you doing?). But I still ended having that guy as a guest in my place for 10 days, which was quite an experience, as those of you who ever met him may imagine, but that is another story (maybe another blog entry, who knows). Ever since, I have been, and continue to be, a vocal proponent of Free Software and Open Source.

On the other hand, I joined Sun Microsystems almost 10 years ago and I have been invovled with Java, one way or the other, since the beginning (1995 and JDK 1.0.2 if you can believe it). And for the past 4 years, I have been integral part of the Java Engineering team, here at Sun.

So, why this rather long, and I apologize for that, disclosure, to the risk of looking like I'm bragging? Because it shows pretty clearly where I come from and where I stand: I have one foot firmly on each side of the fence (and we all know how uncomfortable it can be, specially when said fence is getting taller with each passing day. Ouch!). The being said, it doesn't mean I'm not bragging too.

Now, back to the main point: Sun and the Open Source community. You know, I remember a time when Sun was so completely synonymous of Free Software that almost all Free Software, including the GNU project, the X11 project, and hundreds of others, were developed primarly on Sun's platform. It used to be that the default configuation to these softwares was for SunOS. There were a number of reasons for that, but more importantly, it benefited both sides. And that special relationship is one of the reasons I joined this company in the first place. Then things started to change, and that relationship got looser. If I do remember well, the first release of Solaris (or SunOS 5) was the trigger, for 2 main reasons: First, it was based on a commercial Unix (System V.4 to be exact) instead of BSD. Second, Sun stopped providing compilers for free with the OS (which, to this day, I still think was a major mistake, but that's just me). Since then, both parties have drifted even more apart. And nowadays, most Open Source projects are developed on Linux, to the point where, more and more often, I actually do have to do dome porting (and I do mean the "messing around with the source code" kind of porting) when I want to run some OSS applications on my Solaris box. The horror, the horror! Specially to a guy who fondly remembers the days when he just had to type 'make' and wait for the build to finish.

Now, when Scott McNealy claims, on stage at JavaOne last week, that no other company contributed as much as Sun to the Open Source idea, he is absolutely right! And I wish the community would remember that. After all, aren't they the same people who are big on giving credit when credit is due?

Of course, Sun, as a company, should also remember that it did benefit quite a lot from all the contributions to Open Source. For instance, the main user interface of Sun's products is based on X11, right? And all these sales to academia, among many institutions, were without any doubt helped by the knowledge that there was this huge pool of free software just asking to be run on Sun's hardware! It was, and still is, a two way street. Both side should have realized that a long time ago, don't you think?

Let's talk about OpenSourcing Java, which seems to be the main point of dissension these days. I, for one, would love to get some of the benefits of the Open Source modus operandi when it comes to Java. Particularly as one the developers working on it. I have wished so many times that we could use the "release early, release often" model, and I would love to get direct, or indirect, help (in the form of code, suggestions or discussions) from all these talented developers out there. Also, considering my background, I would love that out of principle

But you know what? It's not going to happen. And it's almost certainly better that way! I won't go over all the arguments again, as you're probably tired of hearing, or reading, about them. Except for the main one: Write Once Run Anywhere is the obvious decisive factor here. I have turned this all over my head many, many times, and I can't figure a way to keep that without a tight control. It's that simple.

Let me also state again, as many have before me, that nothing stops you from creating an fully OpenSource version of Java. At least, nothing in theory, since all specifications are completely open. But I do know that it is incredibly hard! Almost impossibly hard, because there is more to binary compatibility than following the specifications. A lot more. And Sun should acknowledge that.

Which brings me to this question: What can we do to bridge the gap between Sun and the OSS community? How can we get these two, somewhat, estranged friends to be in good terms again?

To the Open Source Community, I'd say: lay off Sun's back a little! And remember to give credit when credit is due for crying out loud!

To Sun, I'd suggest to find ways to make life easier to the OSS developers and distributors. Why can't we have a license that makes it possible to easily redistribute the JDK with every Linux distribution? Why can't we find a way to make it easier for the developers of Kaffe or GNU Classpath, for example, to test the conformity of their implementation? And overall to play nice and fair with the community.

To me it doesn't seem like it would take a lot of efforts to make all this happen. But I have been known, at least to my friends and relatives, to be somewhat of an utopian. But, you know, sometime utopies do happen.


So what do you say? How about being friends again?

(2004-07-08 10:51:08.0) Permalink Comments [8]

20040630 Wednesday June 30, 2004

JavaOne, J2SE 5.0 and Spiderman 2: Go get them Tiger!

Who needs sleep anyway? That's what I was telling myself while leaving Moscone center around 11:30pm after presenting at a late BOF and heading for the Metreon movie theatre, a ticket for the 12:01am showing of Spideman 2 in my pocket.

I love opening nights of long awaited block buster movies! Sure, the line can be a pain, but it can also be quite a bit of fun. After all, the people around you are probably as nut as you are otherwise they wouldn't be here, would they? And, once you are comfortably installed in your seat, nothing beats the atmosphere in the theatre. You can feel the eagerness of the crowd, and you can't help smiling when the audience bursts into applause for such silly reasons as the lights being turned off or the main title starting. There is also something to be said for a pristine copy of the film (of course, this will no longer be an issue once theatres all have switched entirely to digital projection, but it won't happen overnight).

Back to the movie. Peter Parker, and his super-hero alter ego, are back. It's 2 years later and Peter is confronted to a severe case of the "life sucks" syndrome. I won't go into too much details as I hate spoilers and some of the most enjoyable moments of the movie are a lot more fun if you don't know they are coming. I'll just say the opening sequence got the audience, yours truly included, laughing and cheering more than once. And sequences like that abound in this movie. It's refreshing to see a good action/super-hero flick that finds a right balance of action, character development and self derision.

Dang, I just blew it! I already told you the movie is good, while most reviewers would wait until the last paragraph before telling you what they really think, forcing you to go through their whole article in the process. Ho well! I guess you can leave now. Doesn't really matter, it still counts as a hit to this page

Still here? You know, you got way too much time to waste! OK, you asked for it.

It's a fun movie! I could tell you to go and see it, specially if you liked the first one, but it would be a waste, since I know you're going to go no matter what I say! One thing I appreciated is that, as a fan of Spidey when I was a kid, Sam Raimi was able to re-unite me with the feelings I experienced then. Particularly in the "it sucks to be Peter Parker" department. At first, I was a bit uncomfortable with it, thinking it was a bit overdone, but then I remembered that it is exactly what I was thinking back then, while reading the comics. Kudos, at least from me, to the director for sticking with it despite the temptation to tone it down a bit. The actions scenes are top notch, full of energy and, more importantly, they don't feel like you've seen them dozen of times in other movies. They do have a style, a rythm that make them standout.

There is a quite a bit of foreshadowing, specially for the upcoming 3rd installment, but it is rather well done and doesn't stick like a sore thumb. It does flow quite well with the story.

I have just a couple of minor gripes. The middle section could have been shortened a bit, say 10 minutes or so. Also I was not that impressed with Kirsten Dunst performance. She seemed a bit wooden to me. And, last, I felt that some of Aunt May's speeches (you know the "with great powers come great responsibility" kind) were a tad forced. They just didn't seem to come as natural. But, like I said, these are pretty minor and certainly didn't do any damage to the movie overall.

There you have it: Great sequel, can't wait for the DVD, and for once, I'm eagerly awaiting for the 3rd opus hoping they can keep the same level of quality and fun.

One last thing, if you were a JavaOne or an Apple WWDC attendee, as were half of the audience last night, you should have a good laugh at the last line of the movie.

Let me know what you think!

(2004-06-30 10:25:56.0) Permalink

20040628 Monday June 28, 2004

Java: your magic ticket to IPv6

A couple of weeks ago I was in L.A. attending the IPv6 Summit where I was scheduled to make a presentation about Java's support of IPv6. while there, listening to the other presenters I realized something. There is a gap, a disconnect, between application developers and the network infrastructure people. You see, very few attendees were developers, or ISVs, so it felt a bit like most presentations were "preaching to choir" so to speak. Most people in the room were convinced that not only IPv6 was important, but it was also inevitable. It will happen, and, actually it is happening. Many of them were actively involved in making it happen. So how come, when I talk to application developers, they don't seem to care one bit about IPv6 support? Even when their application is heavily networked.


I've been pondering that question for the past 2 weeks and I've come up with a few elements of answer.

First, and foremost, most developers don't know what IPv6 is all about, and when they do know a bit about it they seem to believe that we don't really need it, what with NAT (that's Network Address Translation in case you didn't know) and similar technologies. Second, to most of them, supporting IPv6 means "porting your application", like supporting a new platform that almost nobody is using. In today's market, it's like a death sentence. But it's also a catch 22 situation. You see, many ISPs says they're not deploying IPv6 because there is no demand for it (at least in the US), and there is no demand for it because there are no application for it either. We got a bit of a deadlock here. I'll get back to that later. First I want to address the first point.


Why do we need IPv6? I won't bore you here with all the technical reasons, you can read about it from a number of sources, including at the IPv6 summit website, in particular in the tutorial section, I'll just mention the main 4 ones:

  • Address space
  • auto-configuration
  • end to end security
  • mobility

The first one, of course, is the real kicker: with address length of 128 bits instead of 32, IPv6 makes it possible to assign an address to about any device ever conceived and still not run out of addresses. Couple that with auto-configuration and you won't have to worry about IP addresses ever again.

Now, I know what you're thinking: "NAT solved that problem already". Not quite so, for one thing NAT creates a lot of problems when it comes to end to end communication (think P2P for example), and already some organizations are running out of "private addresses" as defined in RFC 1918. Also, it is has been estimated that if the developing countries (China, India, etc...) get to the point where a mere 20% of their population has Internet access, then we would need 4 times more addresses than are left available, and that's taking NAT into account! So, we don't know when we're going to run out of addresses, but it could happen almost overnight! That's why Asian countries and the European community are pushing IPv6 very hard. On top of that the U.S. Department of Defense (DoD) as announced that they will switch their whole network infrastructure to IPv6 by 2008 and they issued a mandate that, since Oct. 2003, all IT equipment they will purchase, be it hardware or software, has to be IPv6 enabled or have a clear roadmap proving it will be in time. So, if the DoD is one of your customers you probably should worry about IPv6. Same thing is true when it comes to mobile devices, like cellphones or PDA.


So IPv6 is not only needed, it is happening, big time! And, you, developers, should get on the ball!


But, what does it mean to port an application to IPv6? Well, herein lies the "bad news, good news" cliche. The bad news is for applications written in C or C++ (or even C#) the porting can range from simple, for client applications on Unix, to total nightmare, for server applications on Windows (you see Microsoft didn't deem necessary to provide a proper dual stack implementation therefore their IPv6 is the only one I know that is not compatible with IPv4). In any case it means source code changes, new binary relying on new libraries, and, of course, new bugs! Bottom line a lot of work. So what is the good news, you ask? The good news is if you were smart enough to write your application in Java, then you don't have to do anything! You're done. I mean, your code is already IPv6 enabled, you don't even have to recompile. That's right: that application you wrote, and compiled, with JDK 1.1 in 1996 will work just fine on an IPv6 system if you run it with the proper VM (1.4+ for Unixes, 1.5+ for Windows). Let me rephrase that: Any java application (as in the exact same bytecode) will run on any platform whether it's IPv4 or IPv6, Linux, Solaris or Windows! You got IPv6 for free! Remember that the next time you have to convince your management that you should use J2EE instead of .Net for instance!


If you'd like more details about IPv6 and Java, I'd point you to the presentation I made at the IPv6 summit.

In any case, I'll be at JavaOne, so don't hesitate to look me out and ask me any question.

You can catch me at the "ask the experts" booth (don't laugh I didn't pick the name) on Tuesday from 10:30am to 1pm, then at the Technical session TS-2476 on Tuesday from 2:45pm to 3:45pm, and finally we'll have a BOF for Java networking Tuesday at 10:30pm (Esplanade 304/306, Moscone center). I hope to see you there.

(2004-06-28 11:14:54.0) Permalink


archives
links
referers