Posts

Showing posts with the label Java

Mac OS X, Hadoop 0.19.1, and Java 1.6

Image
If you're excited, like I am, about Amazon's recent announcement that they are now offering Elastic Map Reduce you probably want to try a quick Hadoop MapReduce application to test the waters. I found out quickly that if you are on a Mac (as I am) you'll need to perform a few quick configurations before things work correctly. Below is what I needed to do to get Hadoop running on my Mac with Java 1.6. This post assumes you are running the latest Mac OS X 10.5 with all updates applied. Enable Java 1.6 Support To enable Java 1.6, open up the Java Preferences application. This can be found in /Applications/Utilities/Java Preferences. You will need to drag Java 1.6 up and place at the top of both the applet and application versions. Open up a terminal and type java -version and you should see something like the following: java version "1.6.0_07" Java(TM) SE Runtime Environment (build 1.6.0_07-b06-153) Java HotSpot(TM) 64-Bit Server VM (build 1.6.0_07...

Calculating Combinations Using Java and Lots of Bits

I was feeling nostalgic and went back to see how I calculated combinations in Erlang and combinations in Ruby . I wanted to see if there was a fun way to do it without resorting to recursion. I started with my crazy hack to use bit strings to calculate combinations . I didn't want to resort to creating bit strings, as I wanted to minimize the amount of work I needed to do. Therefore, I thought about simply using bitwise operators. Below is my Java algorithm for creating calculations using iteration and bitwise operators to create all combinations from an array. Thoughts? public static void generate(String[] list) { int max = (int) Math.pow(list.length, 2)-1; System.out.println(max + " combinations"); for (long i = 0; i < max; i++) { String[] combo = new String[Long.bitCount(i)]; int comboPos = 0; for (int j = 0; j < list.length; j++) { if ((i & (1L< 0) { combo[comboPos++] = list[j]; } } //System.out.println(Arrays.toString(combo)); ...

QOTD

Coding Horror: Size Is The Enemy Java is like a variant of the game of Tetris in which none of the pieces can fill gaps created by the other pieces, so all you can do is pile them up endlessly.

Automatic Java Class Reloading

I just saw JavaRebel from ZeroTurnaround.com , which promises to "reload changes to Java classes on-the-fly without redeploy or restart including new methods and fields. It is a generic solution that works for standalone Java applications as well as application servers." This is the dream within a dream for Java development. One of the main reasons I moved to Ruby on Rails for web development is due to the much faster development cycle of Change then Test. Back in my Java days, it was Change, Compile, Wait 5 minutes to deploy, Bounce the server, then Test. If JavaRebel can do what it says (and I haven't tried it) then all you Java developers out there might suddenly get a lot more productive. If you've used this tool, drop me a comment.

Comparing Rubyists to Java-ists

...Rubyists tend to function in evangelistic/defensive mode continuously compared to the Java tradition of intense self-criticism... Found in In Relation To...

Bossam Rule/OWL Reasoner

Bossam Rule/OWL Reasoner is another Java based rule engine. It includes a set of rules for OWL reasoning, uses the RETE algorithm, and can be embedded in Java systems. It can reason with Java objects as well as simple facts. Bossam also supports SWRL .

Java.net App Hosting

Hong Zhang's Blog mentions that java.net is now hosting J2EE applications for free through LocalWeb . Here's the quote that scares me: > The actual deployment of an application is done by a small team of engineers from Sun. Yikes. Even with all the deployment descriptors, it takes "a small team" to host and deploy a single J2EE application. There's something wrong with that. I've always said that deploying Java applications is Java's Achilles Heel. The LAMP community mocks Java not necessarily because the language is more verbose, but because it's so dang hard to deploy the applications. Compare with PHP, which is as easy as editing the file and then hitting reload in your browser. That's nearly impossible with a full J2EE application. So many libraries have memory leaks that play havoc with classloaders that a full application server restart is required. In any case, this is one of the main reasons I've been moving to Rails. I ca...

OWL Inference Engine in Jess

OWL Inference Engine in Jess > This page contains source code and instructions to load OWL ontologies and annotations into a JESS knowledge base

Spring 2.0 Auto View Name Generation

Spring 2.0 will have support for autogenerating view names from a request. Rob Harrop has checked in this new strategy interface, reducing the amount of configuration required when writing Spring MVC applications. /** * Strategy interface used to translate an incoming {@link javax.servlet.http.HttpServletRequest} * into a view name when no view name is supplied by the user. * * @author Rob Harrop * @since 2.0M2 */ public interface RequestToViewNameTranslator { /** * Translate the incoming {@link HttpServletRequest} into a view name. * Cannot return null . */ String translate(HttpServletRequest request); } This is largely added in order to simplify working with Spring MVC.

Spring based Application Server

Abstract Horizon has released the Spring Application Server , which is: > Spring Application Server is simple, highly configurable and light-weight application container based on Spring Framework . Server components are POJOs defined under the Spring Framework that is extended to provide support for services. The interesting part is its use of Modules, a concept that Spring doesn't quite have yet. > The server is organised around Modules . Each module describes an unit that exists within a server's boundaries. The modules are organised in a hierarcy of dependancies.

Rails Petstore

The Rails Petstore is > an implementation of Clinton Begin's JPetstore that has been developed with the Rails web framework. The aim of this project is to develop a reference application that demonstrates the capabilities of the framework and the best practices that should be followed when developing an application. This is for all you Java people out there who have seen the Petstore application in one form or another over the years. The Petstore is a common Java application implementation used to show how a framework is used "in the real world". It's been implemented many times, and comparing a Java Petstore to a Rails Petstore is very useful.

Ruby off the Rails

Ruby off the Rails is a look at Ruby from a Java developer's point of view. > Ruby on Rails is just one facet of what makes Ruby great, just like EJB is only part of the Java™ enterprise platform. Andrew Glover digs beneath the hype for a look at what Java developers can do with Ruby, all by itself.

On the Rails Again

Danny's Blog has some good perspectives from a Java guy who just went to JavaPolis, but who is also On the Rails Again . He did pick up on a general meme of EoD: > A lot of presentations I saw, about Java EE 5 (GlassFish) but also for instance about Spring, stressed that everyone now focusses on EoD(Ease of Development) and ‘code by exception’, meaning: only having to code the exceptions to the default behaviour. Having just come back from The Spring Experience myself, and having written Ruby on Rails applications for the two weeks prior, I can attest to what Danny experienced. Programming in Rails certainly opens up your eyes to what else is possible in the web programming world. Not all of it is good, mind you. You immediately miss the power of your Java IDE, for one thing. I recommend that every Java web developer go code a quick application in Rails, even if they will never use Rails again. It's so easy to get caught up in a language's constraints, both physica...

Writing Mixins using AspectJ

java.net has a nice long article on Writing Mixins using AspectJ . They use the example of JavaBean property change event listeners, which up to this point has been a total pain to write. Using AspectJ, you can whisk that code away into its own aspect. Your tradition bean looks clean and beautiful again, while retaining the nice functionality of event listener notification. >Aspect-oriented programming complements object-oriented programming in many ways. One interesting complementary feature is behavior composability. This means that it should be possible to compose a class by adding behavior from different classes. OO uses inheritance and many patterns to add behavior to existing classes. AOP allows us to use mixins without changing the class inheritance hierarchy or otherwise changing the code. >Mixins enable us to uniformly extend a set of classes with a set of fields and methods. Java does not support mixin-based programming. This article shows what mixins are and explain...

More on Splitting Hibernate Jars from Spring

Colin Sampaleanu sheds some more light on why the Hibernate classes were split into their own Jars from the Spring library: > It's not about splitting it out just to split it out. The problem is that having both the Hibernate 2 and Hibernate 3 code together leads to a lot of confusion. People end up importing the wrong classes all the time. The actual class names are identical, and the packages as identical except for one extra char, so it's easy to import the wrong one when you do an auto import in Eclipse. I see this over and over during trainings, among other places. So back in the summer I suggested we split things out to separate jars and have people just include whichever one they wanted, but it didn't make sense (for drop in compatibility reasons) to do this in a 1.2 point release, but rather only now with 2.0...

Spring 2.0 Jar Missing Hibernate Classes

From Craig Walls, explaining what happened to Spring's Hibernate classes in the latest Spring 2.0 M1 release: > I stopped Rob, Rod, and Juergen in the lobby on the last day of TSE and asked the same question. It seems that Juergen has split out most of the vendor-specific ORM stuff into independent JARs (spring-hibernate.jar or spring-hibernate3.jar for instance). It's my understanding that the decision was made because (1) the main JAR was getting quite large and (2) Hibernate/iBATIS/OJB/etc-specific stuff is not central to Spring and thus should not be in the main JAR. > So, yes, from a JAR dependency perspective, backwards compatibility is broken. But fixing it is simply a matter of including an addition JAR file in the classpath. Code-wise, backwards compatibility is still intact.

JavaPolis Spring Web Tier slides

From Alef Arendsen's blog , he has posted his JavaPolis Spring Web Tier slides >Yesterday, Erwin Vervaet and me did a 3-hour session on Spring in the Web Tier. We mainly focused on Spring MVC and Web Flow. The sample is online; you can get to it from the Spring Framework site . >The slides are here , in PDF format.

Ruby to JMS Bindings

You can now integrate Java and Ruby with JMS for Ruby . This implementation uses ActiveMQ as the JMS server. This rocks.

Removing Commons-Logging Once and For All

Removing Commons-Logging Once and For All > I lurk on a bunch of mailing lists via Gmane and recently came across this message in which Henri Yandell asks if it would be possible to write a tool using bytecode manipulation which strips out any dependency on commons-logging. > After getting in touch with Henri he suggested making it a generic tool that could strip out any dependency. That's pretty much right up my alley, and since I've had a few logging headaches of my own I figured it was worth a try. So I've checked in some experimental code to the Jar Jar Links project, which has similar dependency-reducing goals.

Pragmatic AOP with Spring and AspectJ

The final afternoon talk on the final day of The Spring Experience is Pragmatic AOP with Spring and AspectJ. Aspects are modular, enhancing the value of the software overall. Aspects lead to DRY SOCs (Don't Repeat Yourself, Separation of Concerns). Join points are well defined points in the execution of the program. Pointcuts are expressions that match join points. Advice is action to take at those join points. Advice is not explicitly called, unlike methods. Typical applications are Spring managed for data access, services, web controllers, transactions, etc. Up to now, the Domain Model has not been managed by Spring. Spring AOP is a good fit for Spring managed beans, execution based join points, or coarser-grained service application. Or any time where the aspect is slower than the impact of the proxy itself (ie, transactions). In Domain Driven Design, another separation of concern (SOC) is the Technical Concerns (transactions, auditing, etc) from the Business Concerns (the U...