EclipseZone logo image
Thursday, May 17, 2007 

Oracle's new Java EE 5 Server, AJAX Tools, Spring DevKit

Oracle JDeveloper 11g preview: 200+ new features, and 80+ AJAX-enabled JSF components. Oracle Application Server: Java EE 5 compatible, introduces embeddable containers for easier integration with Spring. Oracle TopLink 11g: JPA + JAXB + SDO + more. The new Oracle Development Kit for Spring.

Download it all for free: otn.oracle.com/javaone

 EZ News Corner
dzoneMost-clicked links this week
 
 EZ News Corner
 Next section
Daniel Spiewak is a Java developer and system administrator from Wisconsin, USA. He has over 7 years of experience in the field and specializes in UI design and peer-to-peer networking.

Daniel SpiewakThose Evil Interface Proxies

You know, Java is a really nice language. For having a C derivative syntax, its constructs are remarkably clean and consistent. Java seems to lend itself to well designed libraries and sane APIs. It also has probably the most vibrant community of any language, and definitely the best tool support (three cheers for Eclipse JDT anyone?). However, there are times, when I'm sitting by myself hacking away at some keen idea, that I find myself just gnashing my teeth at the language designers. Seriously, how complicated do these things have to be?!

Not many people know it, but Java has a (theoretically) really nice feature called reflective interface proxying. This allows an interface to be implemented dynamically by another class instance implementing the java.lang.reflect.InvocationHandler interface. All of the calls to the interface instance are dynamically proxied (hence the name) to the invoke(Object, Method, Object[]) method in the proxy instance. This allows you to do something like this:

public TestInterface {
    public void print(String value);
}
public TestProxy extends InvocationHandler {
    public Object invoke(Object proxy, Method method,
        Object[] args) {
        if (method.getName().equals("print")) {
            System.out.println(args[0]);
            return null;
        }
        return null;
    }
}

TestInterface instance = Proxy.newProxyInstance(
	TestInterface.class.getClassLoader(), new Class[]
	{TestInterface.class}, new TestProxy());
Instance.print("Hello World!"); // prints "Hello World!"
//to stdout

Sorry for the verbosity, but this was about the simplest example possible which demonstrates proxying. In this case, it's not really apparent just how powerful this can be. However, one can imagine the possibilities. Other, more dynamic languages (like Ruby or even Objective-C) have this feature in the forms of method_missing and valueForUndefinedKey. Anyone who has used these features will know just how useful they can be. Java's dynamic method handling is obviously much more primitive, and as you can see, much more verbose...

It's really from this that a lot of my headaches for the past few weeks have stemmed. It all began when I was trying to store the proxied objects in a static Map within the proxy handler. This of course requires two critical methods: equals(Object) and hashCode(). Simple enough right? Well, not quite. It seems that while Java does provide the implementations for other methods defined in the Object class, equals(Object), toString() and hashCode() are looped back to the proxy handler. This is really counter intuitive since I didn't think that I overroad those methods, I didn't want to override those methods, and I didn't override those methods. The invocations where just mysteriously dropped into my lap.

The whole proxy API is like this: one kludgy twist after another. And just as soon as you're sure you've got it all straight, some bizarre exception stack trace shows up which ruins your afternoon. In short, it's a devilishly frustrating language feature with precious few examples with which to work.

It's at times like this that I really appreciate some of Eclipse's more basic editor features. Things like inline javadoc, basic content assist and click-to-source stack traces in the Console window. These helpful little tools add can save so much time it's really amazing. I mean, as cool as JavaRef is, I can't say that it's the absolute fastest way to develop when you're forced to look up the documentation at every other method invocation. Really what it comes down to is this: the more I use Eclipse JDT, the more I love its power and simplicity.

Big Ticket Releases
This was actually a fairly significant week, in terms of software releases. VMware announced the much anticipated release of its Workstation 6.0 product, and Eclipse 3.3 M7 showed its face on the Eclipse.org website. By a staggering coincidence (well, not really staggering, it just sounds better that way), these two products have a highly anticipated integration feature, which allows Eclipse to launch (and debug) a Java application within a virtual machine. Actually, this integration has supposedly been available since the second beta of WS 6.0. However, I've never been able to get it to work.

I'm quite literally pulling my hair out over this. Most of the time, Eclipse causes a window of some kind to fire inside the guest OS, but the window disappears and Eclipse hangs forever attempting to make a connection to the virtual machine. If I have Eclipse in debug mode, it will detect a ClassDefNotFoundException just after the window disappears. I've Googled around on this and it seems that this exception occurs when the virtual machines in either host or guest are not Java 5.0 compatible. However, I'm running Java 6.0 in both host and guest so I can't believe that this is the problem. It's really quite strange. If any of you have any ideas on this or have been able to get the Eclipse-VMware integration plugin working, I'd love to hear about it.

Until Next Time,
Daniel Spiewak
daniel@dzone.com

 Tips and Tricks
 
 Tips and Tricks
 Next section
 Back to top
Nearly every day, RJ and others, bring you the hottest tips and tricks from around the Eclipse universe. Have a hot tip? E-mail the editors at editors@eclipsezone.com.
Install JavaFX into Eclipse

Sun have just announced JavaFX, a 'mee too' competitor to Flex and Silverlight. Despite some documentation hinting that it requires NetBeans, there's an Eclipse plugin too.

Full DiscussionPosted By: Alex Blewitt - (12 Replies)

Synchronizing Views with a GEF Editor

View synchronizing is one of the fundamental features for most Eclipse workbench apps. When using a GEF editor, you can use additional views to provide more targeted information about the selection, or even allow editing. There is a lot of good information about this topic - both in the eclipse docs and in the newsgroups. However, I think I can augment that with a concise set of steps for getting this task done quickly.

Full DiscussionPosted By: Adam Cabler - (0 Replies)

Starting Equinox from a Java application

It's possible to bring up Equinox from an existing Java application. This tip shows you how.

Full DiscussionPosted By: Alex Blewitt - (2 Replies)

Run multiple bundle activators in a single bundle

The OSGi spec only allows for a single bundle activator to be executed, but you can chain several together. This tip shows you how it's done, and how you can reuse code by configuration data in the manifest.

Full DiscussionPosted By: Alex Blewitt - (7 Replies)

Configure your projects to use UTF-8 by default

For a cross-platform language, Java does some silly things in using the local character set of the operating system. Unfortunately, Eclipse uses this default for writing source files of most kinds; fortunately, there's an easy way of configuring it to use UTF-8 by default.

Full DiscussionPosted By: Alex Blewitt - (12 Replies)

Add logging with indirection

Ever wanted to add logging or validation to an existing method that you don't have source to? You can easily introduce indirection in Eclipse, re-writing your calls to that method with your own method, and the add the logging to your method call.

Full DiscussionPosted By: Alex Blewitt - (4 Replies)

Join two lines together

Buried in the new-and-noteworthy is a line that simply says "Joining lines in text editors'. A new keystroke, Control+Alt+J, allows you to join lines together in much the same way that J would work in vi, or equivalent text editors.

Full DiscussionPosted By: Alex Blewitt - (8 Replies)

Generate incorrect equals methods with instanceof

Eclipse 3.3M6 allows you to generate equals methods either using the correct getClass() form, or now also an incorrect instanceof form. The choice is yours.

Full DiscussionPosted By: Alex Blewitt - (11 Replies)

Wrapping selected code in a block

An oldie but a goodie -- you can create a selection with Ctrl+Shift+Arrows, and then use Control+Space to insert a multi-line template such as surrounding with try/catch or becoming the body of a while loop.

Full DiscussionPosted By: Alex Blewitt - (4 Replies)

Running 'tail' inside Eclipse

A recent question on Ask EZ about how to tail a file's output in Eclipse prompted me to answer; but in the spirit of sharing the idea with others, I'm posting the reply to the Tips and Tricks page.

Full DiscussionPosted By: Alex Blewitt - (9 Replies)

 Ask EZ
 
 Ask EZ
 Next section
 Back to top
Everyone has questions, especially about a platform such as Eclipse that has so much potential to be customized. EclipseZone comes to the rescue as our editors answer nearly any question you can think of in our Ask EZ forum.
Eclips Config - reg

Want to know how to configure the IDE with Tomcat and WEBlogic servers. I am using eclips 3.2 and Tomcat5.5. Send any documents available

Full DiscussionPosted By: rajendiran - (0 Replies)

How to get eclipse runtime classpath?

I'd like to execute a program out of eclipse IDE. i've recieved some exeptions according to classpath. How to get eclipse runtime classpath? thanks

Full DiscussionPosted By: Alex - (3 Replies)

java.lang.OutOfMemoryError

I get a java.lang.OutOfMemoryError when compiling in the command line even with a simple java program.

Full DiscussionPosted By: Dennis Menor - (3 Replies)

Fragment + Buddy Class Loading

Is it possible to use Eclipse-RegisterBuddy within a fragment and enable other plugins to load classes from the fragment via buddy class loading?

Full DiscussionPosted By: Jörg Lehmann - (2 Replies)

can't see local variables in the debug window

Hi, I'm getting pretty crazy - I'm trying to debug a simple java application. I can't get to see any local variables in the debug window.

Full DiscussionPosted By: Marek Gubco - (0 Replies)

Visual Editor Swing component with nested fields

How to create a Swing (not SWT) component that consists of a panel within which is a JFormattedTextField, a JButton, and a JLabel?

Full DiscussionPosted By: Eli Lato - (0 Replies)

How to create a plugin

I want to create a plugin within Eclipse. I'm trying to modify plugin.xml file but I was having a lot of problems.

Full DiscussionPosted By: Anne - (5 Replies)

Adding Class files to JAR

Attemping to add external class files to a JAR when deploying. I don't have the source code for these classes, and I need them in the base of the JAR

Full DiscussionPosted By: Rene-Jacques Riel - (1 Replies)

BIRT charting api problem to find UResourceBundle class

i'm getting "com/ibm/icu/util/UResourceBundle class not found exception " while trying to use birt charting api.

Full DiscussionPosted By: esamanli - (0 Replies)

WST2.0 not working under Eclipse 3.3M7?

Cannot get Eclipse 3.3M7 to work with WST2.0 under Windows XP -- no XML/HTML editors, no WST preferences, no nothing...

Full DiscussionPosted By: Stanislaw Osinski - (3 Replies)

Mount remote file systems over SSH within Eclipse projects

Mount remote file systems over SSH within Eclipse projects, using the Eclipse File System and Remote System Explorer (from the Target Management project)

Full DiscussionPosted By: jrb - (0 Replies)

A error tip jumps out every time I close my Eclipse

A error tip jumps out every time I close my Eclipse, but not impact the facility Eclipse takes to us.

Full DiscussionPosted By: Minilin - (4 Replies)

importing external jar and exporting into build

need help learning how to export an extenal jar file that is linked to my project to my jar build file.

Full DiscussionPosted By: Marcos - (0 Replies)

remove menubar in openoffice writer document

Hi, I want to remove menubar in openoffice writer document using JAVA, please guide me how to remove it form JAVA. please help me. regards, jeno

Full DiscussionPosted By: jeno - (0 Replies)

How To Theme Eclipse

How is theming properly accomplished in Eclipse? There are some items that aren't lending themselves to straight forward customization...

Full DiscussionPosted By: ylon - (1 Replies)

Launch and Remote Debug in one step?

How can I launch and debug an external process (like Tomcat) in one step? (I can't believe there is a minimum of 100 characters in the summary. Lame!)

Full DiscussionPosted By: Josh Rehman - (0 Replies)

The use of bin folder

Two questions about the automatically generated bin folder for a Java project when a source folder is added

Full DiscussionPosted By: Danny Lin - (1 Replies)

How to attach Javadoc to MTJ Project

How to attach the WTK MIDP API Javadoc to MTJ Project (Eclipse 3.2), so that it can be brought up by pressing F1 key in the IDE

Full DiscussionPosted By: Naiden Gochev - (0 Replies)

reverse uml model?

using free omondo uml to create uml diagrams from several packages, (so far have only been able to create from one)

Full DiscussionPosted By: Elhanan Maayan - (0 Replies)

mannual configaration of Eclipse

i want to configure my "Eclipse" for struts and xml mannually (i didn't had the internet connection to my pc)

Full DiscussionPosted By: Adepu Naresh - (0 Replies)

newbie question

error while deploying MDB in weblogic. i am trying to deploy a simple MDB but receive an error during deployment

Full DiscussionPosted By: Marcos - (0 Replies)

attaching source that i created for jar

problem with attaching a source to a binary jar that was decompiled using "cavaj". Eclipse doesn't recognize the source.i wonder what could have done.

Full DiscussionPosted By: odelya - (1 Replies)

creating Static web site - template based editing

we are developing a web site with html and java script. I need some tool / plugin that has template based editing .

Full DiscussionPosted By: jigar shah - (0 Replies)

Path of a plugin

i created two plugins one reads the input cobol file and another plugin to change this file to a xml file with necessary changes. and its working. bu

Full DiscussionPosted By: kdcosta - (0 Replies)

class/package conflict with a file in the jar library

Name conflict between a file in the included jar and source. Included jar is needed for shared API but also include classes that's under editing.

Full DiscussionPosted By: Tom - (4 Replies)

 Popular at EZ
 
 Popular at EclipseZone
 Next section
 Back to top
A recap of some of the most popular and active EclipseZone discussions this week.
No nested projects for Eclipse 3.3

An oldie but a goodie -- bug 35973 asks for nested projects in Eclipse. It's not going to be fixed in the 3.3 timeframe, but it's been reported no less than 15 times and currently has 58 votes. It's not clear if it will ever get fixed.

Full DiscussionPosted By: Alex Blewitt - (9 Replies)

Subversion binaries for Mac OS X available

Volunteers have released an up-to-date version of Subversion for Mac OS X, at a new open collab.net download site. Is this a one-off, or will it be updated in the future?

Full DiscussionPosted By: Alex Blewitt - (4 Replies)

No more spellchecking in Java string literals

One of the new and nitworthy features in 3.3M7 is the built-in spellchecker. Not everyone liked it though, especially not in Java literals. Fortunately, this has been fixed for the next release, so you don't need to raise it as another bug.

Full DiscussionPosted By: Alex Blewitt - (4 Replies)

Is VE Dead?

Visual Editor is a pretty significant project at Eclipse.org. Unfortunately, I have yet to see anything significant coming from the VE team since the release of 1.2. Is the VE project dead?

Full DiscussionPosted By: Daniel Spiewak - (28 Replies)

Eclipse extensions versus OSGi services

Neil has written an article on the differences between Eclipse extensions and OSGi services. If you ever wondered what the differences between these two models, or even want to know how to process extensions or services, then this article should be interesting reading.

Full DiscussionPosted By: Alex Blewitt - (10 Replies)

 Your Account
 
 Your Account
 Next section
 Back to top
Manage your account info for this and other DeveloperZone publications.
Manage your DeveloperZone membership details

Click on the following links to:


 Contact Info
 Next section
 Back to top
Here's how to reach us, we love to hear from you.
Email us
Send news items to editors@eclipsezone.com
Send questions, complaints, or suggestions to feedback@javalobby.org
Send advertising inquiries to advertise@javalobby.org
 
Call us
Our number is (919) 678-0300. We'd love to hear from you!

 Legal
 Back to top
The fine print we'd rather avoid completely.
Feel free to redistribute this newsletter in part or in full to your friends.

EclipseZone News is a service mark of DeveloperZone, Inc.
Copyright ©2001-2006 DeveloperZone, Inc.

Thank you for your continued support of DeveloperZone. If you prefer not to receive the EclipseZone weekly newsletter, send an e-mail to unsubscribe-eznews@javalobby.org and please ensure the actual email address to be removed is present.
DeveloperZone Inc., 113 Legault Drive, Cary NC 27513 USA