You are currently on IBM Systems Media’s archival website. Click here to view our new website.


Using Open-Source Java From RPG

Open source is a wonderful concept that has caught on in many areas of the IT industry. There are huge, well-respected communities developing software for free that can be utilized by you and your company to meet business needs. These communities are comprised of large corporations like IBM, Intel, Sun, Borland, Computer Associates along with individuals who all have come to realization that if we combine resources to make an end product, instead of going our separate ways, we can end up with tooling that is second to none. Some of the more prominent initiatives are all of the projects being run at, which houses the most widely used HTTP server (Apache) along with many other Java tools, and the popular and ever-growing Integrated Development Environment (IDE) found at (which is what WebSphere Development Studio Client is based on). And then there are entire sites dedicated to hosting open-source initiatives like, and

Where am I going with all of this? Simply put, we're living in an open-source age that's continuing to grow. To date, the iSeries RPG community has seen very little adoption of open-source mediums in relation to the rest of the IT world. A lot of this may have to do with the fact that we're used to writing everything ourselves, but that just can't be the case as we move forward with our IT initiatives. We must learn to leverage code developed by external entities within our programming practices. Think of open source as an extension of your IT department equating to you having many thousands of programming resources at your disposal.

With that, I shift into an example detailing how to utilize open-source Java to send e-mail from your iSeries. As this is geared toward RPG programmers, it's necessary to first wrap the Java code with RPG so it can be easily reused by other RPG programmers needing to send e-mail from their RPG programs.

The open-source Java program I'll be using is JavaMail and can be found online ( Typically, a company would need an employee well versed in Java to interface RPG with the JavaMail API, but by leveraging those who've gone before us, we can take open source, without much Java knowledge, and be sending e-mails from RPG in no time. With this article, you'll realize there's a small set of Java APIs to be aware of, and once the RPG code has been written against them you'll also have an RPG open-source code set. For the purposes of this article, I'll refer to the RPG open-source code set as RPGMail.

The JavaMail API documentation provides a lot of information about specific JavaMail objects and methods, but it doesn't do such a good job of explaining when to use each Java API. I'll use another piece of open source to address that by "normalizing" all those JavaMail APIs down to a handful of easy-to-use Java objects and methods.

The following Java code example shows how to make use of a Java object named RPGMail to send an e-mail.

Aaron Bartell is Director of IBM i Innovation for Krengel Technology Inc. and an IBM Champion.



2019 Solutions Edition

A Comprehensive Online Buyer's Guide to Solutions, Services and Education.

Converting an IBM i Spool File to a PDF

A comprehensive four-step approach

IBM Systems Magazine Subscribe Box Read Now Link Subscribe Now Link iPad App Google Play Store
IBMi News Sign Up Today! Past News Letters