Thursday, December 12, 2013

Five Favorite NetBeans Features

Geertjan Wielenga invited to me to share five of my favorite NetBeans features with Oracle.  Here is the article that I wrote on those features.  When using a great IDE like NetBeans, it is hard to choose just five great features.  I've been using NetBeans quite a few years now, and it just continues to get better with each release.  If you are a developer and have not yet tried NetBeans, I suggest that you give it a try...I think you'll be pleased.

http://netbeans.dzone.com/articles/5-favorite-netbeans-features-joshjuneau

Tuesday, September 24, 2013

JavaOne 2013 - Starting Off Strong

The past two days have been packed with great sessions, and I believe that this year's JavaOne is going very well so far.  After my initial visit to the Schedule Builder, I knew this conference was going to be good.  I found it nearly impossible to choose which sessions to add to my schedule, and which ones to pass up.  There are so many good sessions to choose from, that I am hard pressed to find a time slot that does not contain at least one session that peaks my interest.  

Each of the sessions that I have attended thus far have been packed with excellent information.  It is clear that JDK 8 is a very hot topic this year.  With many sessions covering new features, such as lambda and Nashorn, JDK 8 is everywhere.  Java EE 7 is also a hot topic at this year's conference.  Sessions covering features such as JSF 2.2, JAX-RS 2.0, JMS 2.0, WebSockets, and more...the benefits of using Java EE 7 are clearly being advertised.  Perhaps some of the most widely discussed buzz around EE 7 is the HTML 5 integration.  It is also nice to see some great PrimeFaces coverage at this year's JavaOne.

NetBeans is also getting a lot of coverage this year.  I have attended sessions covering EE 7 tips and tricks with NetBeans, Project Easel, and several sessions on Java EE that demonstrated how powerful the NetBeans and GlassFish combination can be.  I enjoyed the demos of NetBeans and Project Easel being used to develop apps that scale nicely on mobile devices...complete with live debugging on an iOS device.

JavaFX is looking excellent, and the FX team is doing a great job of showing off it's power.  There are many sessions on JavaFX 8, and some great coverage of FX on Raspberry Pi.  HTML5, CSS, MultiTouch...there are countless sessions demonstrating the use of JavaFX with various technologies.

Overall, the most important part of the conference is the community.  The community is stronger than ever this year.  I've met up with so many great faces in Java over the past couple of days.  The Taylor Street cafe is a great place to meet up, and the GlassFish party at the Thirsty Bear was excellent...thanks to the GlassFish team!  The Exhibition Hall and OTN Lounge are always packed...lots of great demos and discussions.

I have the next three days packed solid of excellent Java content...looking forward to many more great sessions!  Java and the community are strong, and it is a great time to be a Java developer.

Keep up with the latest by visiting OTN at oracle.com/technetwork/java


Friday, June 07, 2013

Java EE 7 Books: Java EE 7 Recipes & Introducing Java EE 7

I have been working hard for over a year now on my most recent publication entitled 'Java EE 7 Recipes: A Problem-Solution Approach', published by Apress (May 2013).  This book covers the Java EE stack from the ground-up, and it includes coverage of EE 7 specific features, such as JSF view actions, WebSocket API, and Concurrency Utilities for Java EE.  Therefore, I feel that the book will be a good read for beginner, intermediate, and advanced Java Enterprise developers.

The first chapter begins by walking readers through recipes regarding the setup of a Java Enterprise environment, including specifics on how to install and configure Glassfish v4, a fully Java EE 7 compliant application server.  It then quickly delves into the development of Java Servlets, including coverage of newer concepts such as registering servlets without WEB-XML, and non-blocking I/O.  

Chapter 2 covers JSP from the ground-up.  Although JSP is no longer the preferred option for enterprise application development, it is still a very viable and widely used technology.  Therefore, this chapter will be handy especially for beginner and intermediate level developers so that they can have a better understanding of how JSP technology works, and where it may be the most useful.

Next, the book delves into JavaServer Faces technology, with in-depth coverage that spans four chapters (Chapter 3 - Chapter 6).  Keeping with the theme of the book, readers will learn how to develop applications with JSF, including useful tips and techniques, as well as integration with third-party libraries such as PrimeFaces.  The JSF 2.2 release (which is new with the release of EE 7), includes useful features such as the ability to invoke managed bean actions on life-cycle phase events (viewActions), and better integration with HTML5.  This book will show seasoned JSF developers how to use these new features so that they can begin integrating them into new and existing applications.

No enterprise application would be complete without database access, and Chapters 7 and 8 provide coverage for JDBC and Object-Relational Mapping via the Java Persistence API (JPA).  Chapter 7 provides coverage for utilization of JDBC technology for database access.  The chapter covers everything from obtaining a connection, to handing errors, simplifying connection management, performing CRUD operations, and execution of database stored procedures.  For those developers more interested in utilizing server-side database connection pools, etc., Chapter 8 covers the Java Persistence API.  The chapter contains vital information for working with underlying data stores via JPA including data mapping and entity creation.  It also hits upon EE 7 specific updates, including schema generation support.

Chapter 9 covers EJB technology, along with its new features via the release of EJB 3.2.  Readers will learn how to utilize EntityManagers, differences between Stateless and Stateful Session beans, how to utilize EJB via JSF, and more.  The new features covered include asynchronous message-driven beans (MDB), explicit designation of remote and local interfaces, and opting out of stateful session bean passivation.  In Chapter 10, readers will learn how to query entities using the most up-to-date features in JPQL.   

If you want to work with Java EE 7, you will most likely utilize GlassFish 4 application server since it is the first EE 7 compliant server.  Chapter 11 includes content on how to get up-and running with GlassFish v4, utilizing the administration console for application and datasource management, and setting up authentication.

One of the most popular features of Java EE beginning with the release of EE 6 has been Contexts and Dependency Injection.  Chapter 12 covers CDI in full detail, including recipes on injection, using CDI beans via JSF views, and more.  It also covers new features such as the injection of bean metadata and the new @Veto annotation for marking classes as ignored by CDI.

Have you heard about the simplification of Java Message Service (JMS) in the new 2.0 release?  Readers will learn all about the new simplified JMS API in Chapter 13, along with other JMS basics such as creation of resources, creating/sending messages, and the new message delivery delay.

Chapter 14 is a bit of an extension on Chapter 11, as it covers authentication and security for Java Enterprise applications, specifically those deployed within a GlassFish container.  Almost every enterprise application requires a login form, and this chapter covers how to create one, and also how to utilize LDAP authentication for producing single-sign on solutions.

SOAP and RESTful web services have become significant technologies for the Java EE stack.  Chapter 15 covers web services, both SOAP and REST-based services using JAX-WS and JAX-RS.  Readers will learn how to create each type of web service, and utilize the new features of JAX-RS 2.0 such as the new client API.

Java is not the only language on the block any longer (or JVM, that is).  It is not uncommon to see different languages being utilized to create entire enterprise applications for the JVM, or even for integration with existing Java EE applications.  Chapter 16 includes a few short recipes showing how one may integrate Groovy or Jython into an EE application.

Since HTML5 and the new era of web applications is upon us, the new WebSockets and JSON-P APIs for EE 7 have become of major importance.  Chapter 17 covers these new APIs, demonstrating how to create and utilize WebSockets for full-duplex communication.  The chapter includes an example calling out to a WebSocket from JavaScript.  It also demonstrates how to utilize the new JSON-P API for creating and parsing JSON.

Chapter 18 covers the use of JavaFX for creation of enterprise applications.  It demonstrates how to develop JavaFX front-end applications, and bind them to EJBs for use with data.  There is also a recipe covering the use of JavaFX with RESTful web services.

Finally, both the Concurrency Utilities for Java EE and Batch Applications APIs have been added to EE 7.  These APIs provide a standard for developing concurrent and batch applications for the enterprise. Coverage includes the creation of server-side resources (ManagedExecutorService, etc.) for concurrent application development, and creation of item-oriented batch processes.

Overall, the Java EE 7 Recipes book is perfect for those that are interested in getting up-to-speed with Java EE, including the latest features.  For those who are already experts with Java EE and are only interested in the new features, stay tuned for the release of my upcoming book entitled 'Introducing Java EE 7', to be published by Apress within the next few weeks.


Saturday, November 03, 2012

Java EE 7 by JSR

The following is a listing of JSRs that are contained in the Java EE 7 Specification.

Java EE Platform Specification - http://java.net/projects/javaee-spec/pages/Home 

JSR 107 - JCache https://github.com/jsr107/jsr107spec http://jcp.org/en/jsr/detail?id=107
JSR 236 - Community Utilities for EE http://jcp.org/en/jsr/detail?id=236
JSR 338 - JPA 2.1 http://jcp.org/en/jsr/detail?id=338
JSR 339 - JAX-RS 2.0 http://jcp.org/en/jsr/detail?id=339
JSR 340 - Servlet 3.1 http://jcp.org//en/jsr/detail?id=340
JSR 341 - EL http://jcp.org/en/jsr/detail?id=341
JSR 342 - EE 7 http://jcp.org/en/jsr/detail?id=342
JSR 343 - JMS http://jcp.org/en/jsr/detail?id=343
JSR 344 - JSF 2.2 http://www.jcp.org/en/jsr/detail?id=344
JSR 345 - EJB 3.2 http://jcp.org/en/jsr/detail?id=345
JSR 346 - CDI 1.1 http://jcp.org/aboutJava/communityprocess/pr/jsr346/index.html
JSR 349 - Bean Validation http://jcp.org/en/jsr/detail?id=349
JSR 352 - Batch Applications for the Java Platform http://jcp.org/en/jsr/detail?id=352
JSR 353 - Java API for JSON Processing http://jcp.org/en/jsr/detail?id=353
JSR 365 - WebSockets

Thursday, December 29, 2011

Java 7 Recipes: A Problem-Solution Approach

This is a quick post to mention a new book that will be published soon entitled Java 7 Recipes. I had the pleasure of leading a team of excellent authors: Carl Dea, Mark Beaty, Freddy Guime, and John O' Conner in the authoring of this book. It features a problem-solution approach demonstrating how to get up and running quickly with the Java language. The book features some of the most common questions for newbies starting to develop with Java, and provides answers in an easy-to-learn and reuse manner. It also features some of the most common intermediate and advanced problems and solutions, as well as material that is new to the Java 7 release.

Carl Dea wrote several chapters on JavaFX 2.0, and the material covers enough information to get started with JavaFX 2.0 and then delves into some advanced examples as well. If you are looking to learn the latest in Java desktop and rich internet client development, you will want to check out the chapters on JavaFX 2.0.

Mark Beaty wrote a chapter covering data structures and iteration. He is an expert in object oriented Java concepts, and this chapter covers some of the most fundamental parts of the Java language. Mark also was a technical reviewer for the book, and he did an excellent job of working through the material and solidifying it. I would also like to give a shout out to David Coffin who also performed technical review on several of the chapters...great work!

Freddy Guime is a Java expert who wrote chapters on input/output, exceptions, concurrency, unit testing, and more. Freddy has presented at JavaOne several times and his material exploits his knowledge of the Java language.

John O' Conner has been an avid Java developer for years, and is seasoned in the language. He began his career with Sun Microsystems and helped to develop the internationalization and Unicode support libraries of the core Java SE platform. He authored chapters on those topics for the book, and more.

I authored chapters varying from Strings, object orientation, numbers and dates, database development, and more. We even threw in a chapter on Android so that interested Java developers could take a look at how to develop applications for the Android platform.

Check this book out soon, or pre-order now on Amazon the Apress site. This is a must-have for any Java developer!

I am currently working on my latest Apress book entitled Java EE 7 Recipes...it should be published late next year...stay tuned for more updates on that book!

Friday, March 04, 2011

Django-Jython 1.3.0 Final Available

The Django-Jython project is proud to announce the release of Django-Jython 1.3.0 Final!

This release adds Django 1.3.x compatibility for the Oracle, MySQL, MS SQL, and PostgreSQL backends. Please test with your Django-Jython apps and provide feedback.

Project Home: http://code.google.com/p/django-jython/
Documentation: http://packages.python.org/django-jython/

Thanks to all of those who helped out with this release, your time and effort is truly appreciated!

Support for Django 1.4 is coming soon...

Thursday, March 03, 2011

Jython 2.5.2 Final Released

The Jython development team is proud to announce the release of Jython 2.5.2 final! With this release comes new features, better performance, bug fixes, etc.

For the latest release info, please visit: http://jython.org/latest.html

Thanks to all of the developers for the hard work they put into this release. Looking forward to moving onto 2.6!

Tuesday, December 21, 2010

Oracle PL/SQL Recipes

Since the beginning of my career, I have worked with Oracle databases. I began as a database administrator, monitoring performance and creating database objects. From there, I became a more advanced DBA as I began writing PL/SQL code and creating triggers, functions, packages, and procedures in the database. After a while, I became interested in web application development because I was always receiving requests for creating database reports. Why write a SQL statement and re-run it every time someone wanted to see the output, when you could write a web query that accepted parameters as input and the user could run it on their own? That is the point when I discovered how to do web application development with PL/SQL and the Oracle PL/SQL web toolkit. My good friend and colleague, Matt Arena, showed me the ropes about developing PL/SQL web applications, and it was great! Now I was able to develop web-based queries whenever I had received a request for a report.

After a while, I began to write Java stored procedures because I was developing some sophisticated PL/SQL web applications by that time and I wanted to use some features that the Java language had to offer. Of course, this all worked very well...but I soon gained interest in developing Java Server Pages (JSP) based web Java web applications because they seemed a bit more versatile then PL/SQL web applications. I learned that I could more clearly separate business logic from display code using Java technologies, and began to learn more about it. Before long, I was a full-fledged Java application developer. I was developing Java enterprise applications for Oracle database, and using PL/SQL objects to help facilitate my applications where it made sense.

That brings me to where I am today. I still develop web applications for Oracle database using Java technologies and PL/SQL. I have broadened my horizons by using great languages such as Jython. Life couldn't be much better. This past year, I decided to author a book about PL/SQL that focuses on the basics...but also goes into advanced topics such as working with PL/SQL and Java to develop advanced solutions. I brought my highly respected coworker, Matt Arena, into the book as my co-author. Matt is the most advanced PL/SQL developer that I know, and he wrote the chapters that focus on PL/SQL web application development, collections, PL/SQL jobs, and performance. He taught me, and now he is sharing his great knowledge by teaching others. I authored many chapters that focus on the PL/SQL language fundamentals, and also some advanced chapters working with PL/SQL and Java application development.

Our book is entitled, Oracle PL/SQL Recipes - A Problem-Solution Approach. I recommend you picking it up if you are an Oracle applications developer. Learning PL/SQL is a great asset to any Oracle developer's toolbox. Even if you only work with Java applications, PL/SQL can help you to develop better-performing, and highly robust Oracle solutions. A big thanks goes to Apress and the entire editorial team, including my good friend Jonathan Gennick, who has done an excellent job editing this book. I look forward to working with him again on future projects. I also thank my colleague and great friend Matt Arena for showing me the ropes with PL/SQL web application development...leading my to where I am today in my career.

Oracle PL/SQL Recipes - A Problem-Solution Approach...publishing late December 2010.

Tuesday, October 12, 2010

JavaOne and Oracle Develop 2010 - A New Experience

I took my first trip to JavaOne this year. There were many deciding factors that made me choose to make the trip this year, but perhaps the biggest reason that I attended was due to the Oracle acquisition of Sun Microsystems that took place earlier this year. I wanted to see what Oracle's viewpoint was on the Java ecosystem, and what they planned to do with it over the next several years. I must say that I was pleasantly surprised with the message that I received at the conference, I think Java is alive and very well.

I attended several sessions each day, and the conference made for a very hectic week. I had never visited San Francisco before and I must say that I found it very similar to Chicago. Being a Chicago area person myself, I found nothing overly different about San Francisco as compared to Chicago, but then again, I did not take any opportunities to go sight seeing as I was completely focused on the conference itself.

Having never been to a JavaOne conference before, i think that it was fairly well organized. Now, JavaOne was spread across a few different hotels and one large tent...and in the past I believe that it was centered in the Moscone convention center. I thought that the hotel system worked, but it did make for some rather busy shuffles from session to session. I did like the fact that I had the opportunity to go outside in between sessions though, and since the Mason St. tent was in the center of it all, I could swing by the tent on the way to another session and pick up a coffee or chat with some interesting folk. This really enhanced the experience for me.

The sessions were well thought out and worthwhile. Of course, being a Jython fan I went to as many sessions that were centered on dynamic languages on the JVM as possible. Jim Baker and myself had put in for a Jython-specific talk at this year's JavaOne and unfortunately it was turned down. Our talk was going to focus on the overall picture of bringing dynamic languages to the JVM...and Jython was going to be the example-case. I wasn't too surprised when our session was turned down as there are thousands of submissions, but when I attended the conference it was clear to see why it was turned down...there were several excellent sessions regarding dynamic languages on the JVM already. To be quite truthful, the dynamic language sessions at JavaOne covered several different languages...and I feel that the most used languages on the JVM today were nicely represented. It would have been very nice to have a session devoted to Jython specifically, but the fact is that there are so many dynamic languages on the JVM nowadays, that there was just not enough room for a session on each.

To that end, I attended an excellent JRuby session as my first JavaOne session...it really started my experience off in a great way. The presentation was given by Charles Nutter and Thomas Enebo...a couple of JRuby architects. This was a solid session that really made me want to go and download JRuby afterwards and try it out. Having not tried JRuby prior to the session, I was really focusing more on seeing another dynamic language on the JVM and getting some ideas of how they implemented it. After the presentation, it was clear to see that the JRuby team has a focused effort and is doing very well in porting the Ruby language to the JVM...excellent session.

My second session also focused on languages on the JVM...it was entitled "Multiple Languages, One Virtual Machine". This talk was given by Brian Goetz and John Rose. They did an excellent job of discussing invoke dynamic and what the future holds for dynamic languages on the JVM. It was clear to see that Oracle is putting resource behind offering many different languages on the JVM...not just Java. They are behind the invoke dynamic effort, and it will be included in JDK 7...which is due out sometime in 2011.

I attended many sessions on Java EE 6, EJB, JSF, and other enterprise technologies as I am currently using EJB3 and JSF on many of my projects at work. After attending so many sessions on the EJB 3.1 Lite and JSF 2.0 features, it is clear to see that I need to update my code to take advantage of many of the new features that are available today. It is too easy to get a formula that works and just continue to develop applications using that formula. I fell into that trap over the last couple of years, mainly due to a shortage of time for learning the new stuff. Between my authoring of the Jython book and Oracle PL/SQL Recipes, I haven't enough time to devote an hour a day to learning EJB 3.1, JSF 2.0 or CDI. However, I am making a goal for myself to learn how to migrate my EJB 3.0 code bases to take advantage of the new technologies as I can see from the JavaOne sessions that the newest implementations of the APIs are clearly more productive and easier to manage.

And then there was JavaFX. This technology has always been in the back of my mind as something that I want to learn and begin to use in my projects. I had purchased and read the JavaFX Script book by Jim Weaver a while back...excellent book. As everyone knows by now, it was announced at JavaOne that JavaFX Script will be going away and that the JavaFX API will be changing so that it can be used directly with Java code. This is HUGE news for me as a Java and Jython developer. I attended a great session by Jonathan Giles and Stephen Chin regarding the development of JavaFX applications using alternate languages. They covered JRuby, Closure, Scala, and Groovy in the session. It really looks like the new JavaFX API is going to be great and I am looking forward to writing a JavaFX application using Jython. As a matter of fact, I spoke with Stephen Chin in the Mason St. tent later on, and he was also interested in developing a Jython demo. I hope to see something soon, and plan to develop Jython and JavaFX applications when the new JavaFX API is available.

My parting session was an introduction to Scala. I am glad that I attended this session as well as I have been in the dark about this language until now. I had been hearing lots of good things about Scala, but hadn't found the time to take a look. Attending this session gave me a great overview of the language and really gave me the bug that I needed to put it on my priority list as a language to learn in the coming weeks. Now I need to learn both JRuby and Scala...my time is really going to be growing thin!

Other activities that I took part in included:

Oracle Publisher's Seminar - Since I am writing the PL/SQL Recipes book, I was able to attend this great seminar. It gave me a good opportunity to learn about some Oracle strategies from the team leads themselves, and also meet other Oracle authors.

Jython BoF - Oti Humbel and myself gave a Jython BoF on Wednesday of the conference in the Parc 55 hotel. The BoF was not very well attended, but the appreciation event was also that evening and I suspect that had something to do with it. Overall, Oti and I were able to muddle through the list of open bugs that need to be repaired prior to a Jython 2.5.2 final release. I had a great time meeting with Oti and look forward to working with him on Jython for future releases. We also met with Frank Wierzbicki, the Jython project lead and one of my co-authors for the Jython book. It was great to talk Jython for a while with a couple of the core devs, and to strategize about future Jython developments.

Keynotes - The JavaOne keynotes were okay...lots of hype around the future of Java and JavaFX. Glad I attended them for the experience, but nothing too earth shattering. My favorite keynote was the Oracle Develop keynote by Tom Kyte. I have been a big fan of Tom Kyte for several years as he is a lead in Oracle database technologies and PL/SQL. Excellent keynote with some great insight on Oracle 11gR2 and some of it's new features (some that I have not used yet!).

JavaPosse - Perhaps the highlight of the conference for me was the JavaPosse BoF and rooftop party at the Passion Cafe. I listen to the JavaPosse religiously, and finally having a chance to see the crew in person and have drinks with them after the BoF was a great experience. They are truly great people who do an excellent job with the podcast. Thanks JavaPosse crew, excellent show at JavaOne.

So JavaOne 2010 was a new experience for me. I think that it was a great experience and I would be happy to attend another JavaOne at some point in the future. I think that given the atmosphere and the dynamics of the conference, it was a new experience for even those who had attended in previous years. It is nice to see that Java is in good hands with Oracle, and I am looking forward to a bright future.

Wednesday, March 24, 2010

Working with Images Using Django on Jython

If you've tried to use Django on Jython along with an ImageField, you know well that Django on Jython does not support this field. This is because the ImageField in Django relies on the Python Imaging Library (PIL). Jython does not support the PIL since it is C based, and there is not currently a version of the PIL that has been ported to Java.

That being said, how do we make use of images in Django on Jython? Since the ImageField is not usable from Django on Jython, we need to use an alternate method for uploading and displaying images. The following is a solution I've been using for one of my applications. This is certainly not a perfect solution, nor do I think we should modify Django on Jython to support this solution out-of-the-box. However, it works and gets the job done.

In order to use images with Django on Jython, you need to make use of the FileField. Since the FileField does not display in a template as an image, it is also a requirement to tweak the template which will be displaying the images with an ordinary "img" tag. Also, to make things work nicely, it is important to code a variable...we'll call it "image_src"...with the path to the image that will be displayed. This is done within your views in views.py. Of course, images will take the name attribute of your FileField, but you must prefix that name with the path to your web server. So my solution for this is to create another variable, say PHOTO_ROOT, in the settings.py and we will set it equal to the web server's MEDIA_ROOT location.

Lots of steps to make a usable image? Not really, it may seem daunting at first glance, but it does work easily once you've got it down.

Steps for using images with Django Jython:

1) Create a FileField in your model to contain your image information. Be sure to indicate where you wish the image to be uploaded to by specifying the "upload_to" attribute.

For example, in the following case the "images" directory which is specified by the 'upload_to' attribute exists directly under the MEDIA_ROOT root:

class MyTestModel(models.Model):
photo = models.FileField(upload_to='images', blank=True)


2) Create a variable within settings.py to contain the path to your web server's MEDIA_ROOT location. Please note that this will need to be changed when you deploy to different environments (ie: development or production).


PHOTO_ROOT = 'http://localhost:8000/site_media/'


3) Add a variable to your views through which the image path will be exposed. This variable will need to contain the PHOTO_ROOT you specified in settings.py, as well as the appended file.name for the FileField containing your image. Therefore, you will need to code a line in each view you wish to expose the image through.

In order to make your UI slick, it is a good idea to use a default image for any records that may not have an image uploaded. You can assign the path for that default image to your variable if your FileField does not contain anything.


# Be sure to import your settings file
from django.conf import settings
...
# This code contains relevant portions of a detail view for displaying or modifying
# a record
def detail(request, record_id=0):
...
record = get_object_or_404(MyTestModel, pk=record_id)
form = MyForm(instance=record)

# Check to see if the FileField (photo) contains anything
if record.photo:
image_src = '%s/%s' % (settings.PHOTO_ROOT, record.photo.name)
else:
image_src = '%s/images/nophoto.jpg' % settings.PHOTO_ROOT

...
return render_to_response('detail.html',
{'form':form,
'image_src':image_src})



4) Add an "img" tag to your template in order to display your image. You must also add the "form.photo" field to the template in order to have the ability to upload an image.



some_content
...


{{ form.photo }}

<img title="Photo"
src="{{ image_src }}"/>


...
more_content


That is basically it. When you view the record initially, the default image should appear. After an image is uploaded successfully, it should replace the default image.

Wednesday, March 10, 2010

Received Author Copies of The Definitive Guide to Jython

For the past few weeks since The Definitive Guide to Jython had been published, I've been checking my mail often in anticipation of seeing our book in print for the first time. Well, today my copies finally arrived and it is great. It is excellent to read the printed copy...and it will definitely be nice to have on my desk while I'm coding some Jython.

Thanks again to all of my co-authors, the technical reviewers, editors, and everyone else involved in the publishing of the book. It is a great resource and I am glad to be a part of it. Looking forward to working on the second edition in the not too distant future!

Now, onto more coding...

Wednesday, February 03, 2010

Jython Book - Working with the Sources

The open source version of 'The Definitive Guide to Jython' (aka: Jython book) is available online, both in restructuredText format and HTML via Sphinx. Apress was good enough to send me the final versions for all of our chapters and appendicies in MS-Word format. It is my task to convert them from MS Word format into restructuredText...which is a slow and sometimes painful process.

Overview of Conversion Process

1) Open the MS-Word document in Open Office (my preference) and remove headers and footers from each page

2) Save the document in open office format

3) Try to apply the apress_odt_to_rst.py script that was donated by James Gardner. If that doesn't work, then save document in HTML format and use pandoc to convert.

Command: pandoc -t rst filename.htm > filename.rst

4) Manually parse through each rst file and repair issues (and there are usually a lot...especially with code markup and tables)

Interested in building the sources?

If you are interested in building the sources, you can check the out from bitbucket.org at the following link: http://bitbucket.org/javajuneau/jythonbook/ and then build them using Sphinx

View the Open Source Book

If you'd like to simply view the open source book, it can be found at http://jythonbook.com in Sphinx format. We of course recommend that you purchase a copy of the book from Apress to keep handy as well so that you can mark it up, make notes, etc. However, the open source version will be continually updated and it will be great for using as a quick reference while online.

Monday, February 01, 2010

The Definitive Guide to Jython Is Published

The Definitive Guide to Jython: Python for the Java Platform has been published. This is a work in which five authors: Jim Baker, Victor Ng, Leo Soto, Frank Wierzbicki, and myself, began to author early in 2009. The book covers much detail on the Jython language and it's usage. It was a much needed addition to the library of Jython books that are available today as this book focuses on Jython 2.5.1...the most current release to-date. Many methodologies that hadn't been formally documented previously, such as the object factory pattern, with-statement, django and jython, and concurrency, have been documented in detail in this text.

If you are interested in developing with Jython, I recommend you take a look at this book today. There is also an online open source version of the book that can be found at http://jythonbook.com, but all of it's contents have not yet been updated to include finalized versions of all chapters. I am working on converting the .doc formatted final versions into restructured text at this time, but it is a lengthy process.

Thanks to all of my fellow authors and to the team at Apress for all of their hard work!

Wednesday, September 16, 2009

Jython 2.5.1rc2 - zxJDBC with-statement

This past weekend (09/12/2009), the Jython developer team rolled out the second release candidate for version 2.5.1. In the release were many bug fixes and some additional features...I definitely recommend downloading it and trying it out if you haven't already done so. Thanks to all of the developers who have made this release possible.

One of the features added in this release for database work with the zxJDBC API is with-statement compatibility. Thanks to Jim Baker for updating the PyConnection and PyCursor objects in Jython so that it can now be used in the context of a with-statement. This can be useful for maintaining resources and transactional state when working with databases.

To use the new feature, you must import the closing() function from contextlib so that the connection can be bound to a variable and closed at the end of the statement. Use of this feature works as follows:


# In this example, I am connecting to a postgresql database.
# Of course, we could connect to the database of our choice so long
# as we have the appropriate JDBC driver in our CLASSPATH

>>> from __future__ import with_statement
>>> from com.ziclix.python.sql import zxJDBC
>>> from contextlib import closing
>>> jdbc_url = "jdbc:postgresql:mydatabase"
>>> username = "postgres"
>>> password = "mypass"
>>> driver = "org.postgresql.Driver"
>>> with closing(zxJDBC.connect(jdbc_url, username, password, driver)) as conn:
... with conn:
>>> # Use one or more cursors within the context of the with-statement
... with conn.cursor() as c:
... c.execute("select name from country")
... c.fetchone()
...
(u'Afghanistan',)


In the example above, I queried a database table. However, we could use the cursor in any way that we'd like within the context of the statement. Use for transaction management and if an error occurs within a transaction then everything is rolled back.


>>> with closing(zxJDBC.connect(jdbc_url, username, password, driver)) as conn:
... with conn:
... with conn.cursor() as c:
... try:
... stmt = "insert into country values (?,?)"
... # the following produces an error
... c.executemany(stmt, ['test'])
... # perform more inserts and updates
... conn.commit()
... except Exception, err:
... raise Exception("There has been a zxJDBC error")


Transaction management is taken care of such that if a statement fails, then the complete transaction is rolled back. This is very useful for transaction management. If you attempt to work with the cursor or connection outside of the statement then it will not work because the statement closes them after use. That is the beauty of using the with-statement for resource management. The with-statement is also nice for working with files and such in a similar manner.

For more information on the use of the with_statement, please visit PEP-343 or the open source Jython Book (In Progress) which will soon be updated to illustrate correct usage of with-statement context management for zxJDBC in 2.5.1.

Enjoy!

Thursday, July 02, 2009

The Definitive Guide to Jython - Open Source Version

Start reading the open source version of 'The Definitive Guide to Jython'. This book is currently being authored by Frank Wierzbicki, Jim Baker, Leo Soto, Vic Ng, and myself. It is due to be published by Apress in the fall of 2009. I am having a great time being part of the project and really appreciate the opportunity! I thank Jim Baker for contacting me in regards to the book and giving me the opportunity to become the lead author.

The book is available in restructured text format on the kenai.com website as the jythonbook project. You will find the Sphinx formatted book here for the time being, but we will migrate it to jythonbook.com in the near future. We encourage comments and suggestions.

A special thanks to James Gardner for his help on providing us with the tools to convert the book into restructured text format. I plan to have a post dedicated to my work with converting from Word to rst and vice versa sometime in the near future.

Our book is focusing on the 2.5 release of Jython, which you can download here. It goes through the Python language basics through some advanced concepts. The book then goes into Jython-specific topics such as java integration and the like.

We hope you will find this book useful. Stay tuned for more to follow on the book...

Tuesday, June 16, 2009

Jython 2.5.0 Has Been Released

Jython 2.5.0 has been released! This release includes many new language features for Jython bringing it inline with more modern releases of Python. This is a big release and I congratulate all of the developers!

Go and download today from : http://www.jython.org

Friday, April 10, 2009

Netbeans Articles

James Branam has recently turned a couple of my Python/Jython tutorials for Netbeans 6.5 into Netbeans.org articles. Check them out:

Developing a Jython App in Netbeans

Python Quickstart

If you haven't tried Netbeans out for Jython or Python development, now would be the time...it is great!

Sunday, March 29, 2009

The Definitive Guide to Jython...Fall 2009

A new Jython book will be published by Apress this fall entitled 'The Definitive Guide to Jython with Django'. Authors include Jim Baker, Frank Wierzbicki, Leo Soto, Victor Ng, and myself.

This book will be of interest to those beginning Jython and also to advanced users. We will also maintain an open source version of the book online.

I'm looking forward to working with these talented individuals and assisting in the documentation of Jython.

Tuesday, February 24, 2009

EMD Upload Error: Oracle Enterprise Management Agent

I came into work on Monday and saw that all of the databases which are running on our development database server were no longer reporting to our Oracle Grid Control. After looking at the Grid Control server, I realized that the management agent was not functioning correctly. Time to investigate...

I went to the command line and issued the following:


emctl status agent



Everything looked fine, but then I realized that the "Collection Status" indicated that it had been disabled by the collection manager. In my case, this had occurred because over the weekend I had been moving some files around and filled up one of the disks on the server completely. Realizing I had done so, I immediately removed some of those files to free up disk space. Unfortunately, this disk which filled up was the same one on which the Oracle Management Agent is installed. Being that the disk filled up and that the collection manager was not able to add the required XML files to disk, it immediately disabled itself.

The remedy: Of course, ensure that the disk has available space. Once you've done so, simply restart the management agent. It will begin working immediately.

Thursday, February 05, 2009

Developing Django-Jython Using Netbeans

If you are interested in using Django on Jython, then you will need to incorporate the Django-Jython project into your Jython installation after Django has been installed. The Django-Jython project facilitates the use of Jython's zxJDBC database infrastructure in order for Django to access database backends. At this time, the only fully supported database is Postgresql, but there are also experimental backends for using SQL Server, sqllite, and Oracle under development. In order to use Django on Jython with another database or to assist in the development of these backends, you will need to download the Django-Jython project source code and write your own backend or update one which already exists.

Working with the Django-Jython project using a text editor is one way to go, but if you are used to the automation and simplicity of using an IDE, text editing can be a painful experience. This blog will walk you through the steps of setting up an environment within Netbeans 6.5 for developing the Django-Jython project.

The process of development with Django-Jython is as follows:

1. Download source for project

2. Add/Modify source code to facilitate your needs

3. Build the source and install it into your Jython home

Number 1 above is easy enough, just visit the Django-Jython project page. However, numbers 2 and 3 are manually performed processes. You can help to automate these processes by using the power of Netbeans. Simply follow the procedure below to set up the environment:

1) Create a Python project with existing sources and name it something like "DjangoJython"




2) Add the root-level directory of the "django-jython" source folder to the "Source Root Folders" window area when creating the project, then click finish.


At this point your project will be created and you can work with the source. However, we need a way to tell the IDE to build and install the project. You can either use the command-line to do so by traversing to the project folder and issuing:

jython setup.py build, followed by, jython setup.py install

Or, you can perform have Netbeans IDE build the project for you when you invoke the "Run" process on the project by performing step 3.

3) Right-click on the project, and choose "Properties". Select the "Run" category and then enter "setup.py" as the main module and enter "install" into the application arguments text field. Now, each time you elect to "run" the project, it will cause netbeans to build and install it.




The only caveat to using this method of building and installing Django-Jython is that you will need to manually delete the "build" directory in your DjangoJython Netbeans project as well as delete the "doj" directory from your Jython installation (Jython-Path/Lib/site-packages/doj) prior to issuing "run" each time. I have found that if you do not, sometimes all of the updated modules are not reinstalled. Deleting these directories prior to running your build/install forces a new build and install to take place each time.

Now, enjoy the great development experience of Netbeans while contributing to a great project...Django-Jython! Have fun!