Archive

Archive for the ‘Java’ Category

Sun to be bought by Oracle for $7.4 Billion

June 14th, 2009 deevis No comments

I’m a little late on this to really consider it news in the sense that news is usually new.  And I must admit I was sceptical when I first heard it, but it’s true.  Sun themselves admit it : http://www.sun.com/aboutsun/pr/2009-04/sunflash.20090420.1.xml.

The mighty behemoth, proprietary squelchor of innovation, and extremely expensive Oracle is about to acquire the open-source, free, and always innovative Sun ( and with that Java!).  Anyway I look at this it sucks – for Java, at least.  This will, in my humble opinion, accelerate Java’s path to Cobol – which it is destined to become as more agile languages come to maturity and continue to grow in popularity ( ruby, python, erlang ).

Rod Johnson, with Spring, is singing an optimistic tune ( Spring Keynote Address on Future of Java ) .  One that talks about Java having reached maturity and that it doesn’t really need to evolve anymore.  C doesn’t really evolve – it does what it does and does it very well.  As Rod says, “It doesn’t pretend to be C#.”  Point taken.  He goes on to say that in many ways the innovation in the Java community has already moved outside of the Java core.  Language improvements include Groovy and Scala.  Framework improvements come in the form of Grails ( and, he doesn’t mention this, Seam ).

Rod’s address is largely true, but it is also to drum up excitement for their new application generation project ROO.  This gives alot of the functionality one would get from Rails or Seam, but does things within a shell rather than all command line.  This is actually kind of nice because the shell can keep track of the context each subsequent command is running in and also allows for some pretty snazzy auto-completion features.

Should we Javaheads run around screaming the sky is falling?  Probably not.  But if we don’t get up to snuff with Grails and new projects like Seam and Roo which look to make things a whole lot RAD-der, then we’d better accept our role as stewards to the next generation of Cobol applications.

One more thing – Ruby, for example, is still missing a lot of enterprise tooling which we take for granted in the Java world.  Applications like JConsole and JProfiler don’t yet exists – so another way to look at this is on the larger programming stage, where what we’ve learned with Java should be created for Ruby, Python, and Erlang to ease the passing of the torch when the time comes.

Categories: Java, Spring Tags: ,

Java 101: building your java classpath from a lib folder

February 23rd, 2009 deevis No comments

OK – I admit it – my IDE and tools make me weak in many ways.  I was just having the hardest time getting my maven-managed project to run from a basic “java my.class.ClassName” command line invocation.  Why?  Because the freaking classpath is a million miles away from being a concern to me anymore.  So, jog the memory and immediately remember the -cp ( or -classpath ) option.  Also remember that I cannot specify a directory if I want to include all of the jars in that directory ( specifying a directory in the classpath will only load exploded .class files! ).

What I’ve got before me is a target/lib directory full of all of my maven2-managed dependencies.  I need to add each jar file explicitly into the classpath – barf!

Well, here’s a handy little shell script which will build that string for you:

for file in `ls lib`; do echo -n ‘lib/’ >> classpath.txt;echo -n $file >> classpath.txt;echo -n ‘:’ >> classpath.txt;done

Awesome – so just open the classpath.txt file and use that big ‘ol path however you want to.  Windows users would use a semi-colon instead of a colon above.  Also, remember that you need to specify the classpath option prior to the name of the class to run – otherwise the classpath is ignored ( as it is assumed to be an argument to the program and not a jvm option ).

Categories: Java, Linux Tags:

A Conventionally Annotated Configuration – Spring, Hibernate, Eclipse

February 18th, 2009 deevis No comments

I’m starting on a personal project and decided I was going to take the time to do things right.  This means different things to different folks, but to me it basically entails:

  1. Using the latest and greatest versions of everything.  Eclipse 3.4.  Hibernate 3.3.1.  Spring 2.5.6.  Tomcat 6.  Maven 2.0.9.  Java 6 ( 7? ), DWR 3.0.
  2. Using Eclipse plugins to do as much as possible without causing headaches
  3. Using as little XML configuration as possible – conventions, conventions, conventions!!!
  4. Using JPA annotations for ORM classes.
  5. Using Annotations for IOC dependencies.
  6. Using Annotations for Transactional demarcation.
  7. Using Annotations for MVC mappings.
  8. Using very basic JSTL-based JSP’s for views.
  9. Using Sitemesh to present a uniform look and feel across all pages.
  10. For icing on the cake I’d like to also include GWT components.

Using the latest and greatest versions of everything
If you install Eclipse 3.4 first, and then install the Maven Integration plugin, it will greatly simplify things.  Just add Maven Integration to your project and then use “Add Dependency” option to quickly scour the entire repository and find the exact groupIds, artifactIds, and versions you want.  It also has a great view of the dependency hierarchy!  Getting all of these bleeding-edge versions to play nice together has its fair share of challenges.

Using as little XML configuration as possible

Using Eclipse plugins to do as much as possible without causing headaches

I already mentioned Maven Integration above to help with getting the LAGV of all the technologies being used.  Also of great value and import are SysDeo and  Subclipse.  Sysdeo is great for deploying and debugging your webapp in Tomcat.  Subclipse is great for seamless integration with an SVN repostiory.  Yes – use SCM on personal projects, you never know when you’ll need to revert or bring the code down onto a new machine.

But where do we draw the line here?  When do we have so much annotation cruft that an externalized xml configuration will seem like the ideal solution ( from whence we currently come in search of clarity! ).

Using very basic JSTL-based JSP’s for views
OK – well, tonight I was getting ready to put together the first couple of jsp’s now that the @Controller mappings are working and the pages are being served correctly.  I’ve got the method mapped correctly with @RequestMapping and I’ve got the model being put into pagescope with @ModelAttribute.  I’m ready to loop through a List using JSTL forEach.  But wait, can this possibly be true?  Tomcat6 has no implementation of JSTL.  JSTL 1.2 is the LAGV and the JSTL 1.1 is abandoned.  Only *Glassfish* ships with the reference implementation of JSTL 1.2?!?  Oh brother.  Thanks to Peter Mularien for writing a nice post informing me of this.

As if needing to download and install glassfish in order to get the JSTL 1.2 implementation jars for Tomcat6 wasn’t bad enough, well I hit a couple more snags after that.  First of all, I want to know who decided on the namespaces for JSTL 1.1 vs 1.2.  Here they are:

1.0  == <%@taglib prefix=”c” uri=”http://java.sun.com/jsp/core” %>

1.1 & 1.2 ==<%@taglib prefix=”c” uri=”http://java.sun.com/jsp/jstl/core” %>

I mean all they did was add the “jstl” into the path?!?  I’m supposed to remember this?  OK – I’ll try harder to remember for next time.

Then, I learned that Maven2 doesn’t copy “system” provided jars into WEB-INF/lib by default and they need to be placed there manually as part of the project.  So, the appserv-jstl.jar I copied from glassfish wasn’t being included because I linked Maven to it as a system ( vs provided, or compile, or test, etc… ) dependency.