Activate your free membership today | Log-in

Thursday, September 3rd, 2009

JavaScript on the command line or as a shell scripting language

Category: Java, JavaScript

I am always fascinated that no matter how shiny the OS, sooner or later you'll end up typing things into a text console to get the darn machine to do what you want it to. To make matters worse you also have to resort to languages that you don't use every day but are from cryptic days of development where keyboards obviously had more interesting characters like ~ | -- and others easily available and scripts had to have numerous | in any line of code.

Enter Stoyan Stefanov who wrote a neat little blog post explaining how you can use JavaScript as a shell language.

In essence, Rhino is the answer for *nix machines but if you cuddle the penguin you most likely are a shell master anyways.

If your world features Gates and Windows, then there is the Windows Scripting Host, which has a tool to execute JavaScript on the DOS shell:

JAVASCRIPT:
  1. C:\> cscript jslint.js

Macs have a tool called JSC which is "conveniently" located in:

JAVASCRIPT:
  1. /System/Library/Frameworks/JavaScriptCore.framework/Versions/A/Resources/jsc

To make it human usable, creating a shortcut is a good plan:

JAVASCRIPT:
  1. $ sudo ln /System/Library/Frameworks/JavaScriptCore.framework/Versions/A/Resources/jsc /bin/jsc

You can then execute JavaScript by starting JSC which gives you something like the Firebug JS console in the OS console (without the console is not defined messages *in* the console).

With a few more lines using the print(), quit() and load() commands available on the shell you can then use any JavaScript to mess with your files and folders.

Posted by Chris Heilmann at 7:25 am
16 Comments

++++-
4.2 rating from 21 votes

Friday, March 27th, 2009

Transparent Comet with IceFaces

Category: Comet, Java

We recently posted on Atmosphere, a new framework designed to provide an abstraction layer over Comet back-ends for Java web applications. At a personal level, this comes at an interesting time as over in the Mozilla Labs we're evaluating different Comet approaches for our upcoming collaboration release. As we looked at various options, we come across some recent postings from Ted Goddard of IceFaces fame explaining their work on making Comet as simple as possible for Java developers, including a podcast and an overview of the IceFaces approach.

Say what you will about JSF, their abstraction layer makes server and client implementation of Comet incredibly simple:

In other words, we can re-use our existing Ajax pipeline, and the application developer only needs to worry about one thing: requesting that a page be rendered. As you can imagine, this is only a few lines of code. With ICEfaces it looks like this:

JAVA:
  1. SessionRenderer.addCurrentSession("ajaxian");
  2.  
  3. // somewhere else in the presentation tier
  4. SessionRenderer.render("ajaxian");

Not only does the application developer not have to worry about low-level protocol details or messaging, they don't even have to worry about what has changed on the page -- this is all taken care of by the declared binding between the page and the model.

To summarize: we have dynamic pages that can be rendered on the server at any time, and the updates are pushed to the browser where the changes are applied to the DOM. From the application developer's point of view, that's all there is to it.

Are you using a stack that makes Comet this easy? Have you been able to successfully implement Comet? Do you get sufficient performance from polling?

Posted by Ben Galbraith at 7:00 am
9 Comments

++---
2.1 rating from 103 votes

Monday, March 16th, 2009

Atmosphere: Comet Abstraction Framework

Category: Comet, Java

Jean-Francois Arcand announced a new Java-based framework that clients can code against for portable Comet support:

Atmosphere 0.1-ALPHA1 is now officially released and support Tomcat, Jetty, Grizzly and GlassFish. Finally a Comet/Ajax Push framework you can build on top of it and deploy everywhere!

One of the cool features of this release is that it auto-detects which server back-end you've deployed it into.

Among the materials in the release notes are two code samples and a PDF discussing what Comet is and the motivation/design behind Atmosphere.

Comet on Java just got easier, which is a welcome development indeed.

Posted by Ben Galbraith at 8:29 am
5 Comments

+++--
3.8 rating from 17 votes

Tuesday, March 10th, 2009

IT Mill Toolkit 5 out of Beta

Category: Framework, GWT, Java

With the release of IT Mill Toolkit 5.3.0, the server-side RIA framework is now ready for production. I announced the initial release of 5.0 back in December of 2007. Since that time, IT Mill 5 has gone through several revisions and the release of GWT 1.5 (which means you can use Java 5 now on both the client and the server). As a reminder, server-side RIA frameworks let you write your app completely in the server and uses a client-side Ajax engine to render the interface. The nice wrinkle with IT Mill is that both the server side and the client side are written in Java, so if you want to add a component, you don't have to break out the JavaScript (see the extensive and high quality reference manual for details on how to develop your own custom components in GWT). If you're a Java shop, that's got to be a good thing.

Posted by Dietrich Kappe at 5:24 pm
10 Comments

+++--
3.8 rating from 44 votes

Sunday, March 1st, 2009

The Most Popular Sessions at TheServerSide Java Symposium

Category: Conferences, Java

TheServerSide.com's Java Symposium kicks off in less than 2 weeks! Our sister site has put together an impressive lineup of speakers and over 45 tech sessions and case studies that you should know about, like Identifying Browser Problems in Ajax Apps, Meet-up for Selenium, soapUI, HtmlUnit and Other Test Tools and much more.

And if you haven't heard, Ajaxian members save an extra $100 off the registration fee with the code AJAXIAN!

The full agenda is available online, but here's a sneak peek of the 5 most popular sessions being presented at TSSJS:

1. Building Next-Generation Web Applications with the Spring 3.0 Web Stack with Jeremy Grelle, Senior Software Engineer with SpringSource

2. Spring for the Advanced Java Developer with Rod Johnson, Creator of Spring

3. Just Enough Early Architecture to Guide Development with Jon Kern, Co-author, The Agile Manifesto

4. Hibernate Search: Finding Data, You Deserve Better with Emmanuel Bernard, Lead Developer of Hibernate Search

5. Navigating the SOA Mine Field Optimized Application Architectures with Heath Kesler, an open source software evangelist

If you'd like to attend simply register with the code AJAXIAN to take $100 off the registration fee.

Posted by tberardi at 8:10 pm
1 Comment

+++--
3.5 rating from 15 votes

Friday, February 27th, 2009

Ghosts in the machine – avoid using window.sun in Firefox as it starts the Java engine!

Category: Java, JavaScript, Mozilla

Sometimes you find leftovers of old technology in browsers that blow your mind. One of these "ghost in the machine" problems exists in Firefox: if you use window.sun or function sun() in JavaScript you effectively start the Java VM.

There are a few "magic" properties on Mozilla's DOMWindow interface for supporting LiveConnect that will initialize the Java plugin and all the baggage that comes with it (which, with modern Java plugins, means launching java.exe as a subprocess). Looking up these properties on the window object is all it takes.

There are a few more of these still in the Mozilla source code and they are part of the old Netscape LiveConnect engine. They are:

  • java
  • Packages
  • netscape
  • sun
  • JavaClass
  • JavaArray
  • JavaMember

Avoid these at all cost lest you want the performance of your JavaScript to be like a Java Applet.

Posted by Chris Heilmann at 2:18 am
8 Comments

+++--
3.7 rating from 16 votes

Monday, February 9th, 2009

Ajaxian Offer: $200 off expires this Friday

Category: Conferences, Java

This Friday is the LAST CHANCE for Ajaxian readers to save $200 off TheServerSide Java Symposium, an event hosted by our sister site TheServerSide.com.

Every little bit helps in this economy - register today with the code AJAXIAN to pay only $1495 for the conference, coming to Las Vegas March 18-20.

You don't want to miss:

View the complete agenda and register to save $200.

Posted by tberardi at 2:01 pm
Comment here

++---
2.1 rating from 19 votes

CP2JavaWS: GWT like Cappuccino to Java remote services bridge

Category: Java

Jerome Denanot has created CP2JavaWS, an open source "bridge between Cappuccino rich desktop applications and Java services deployed on a web server. It consists of a proxy (client side) and a servlet (server side), and manages parameters namespace, encoding, ordering and JSONP."

Jerome told us more:

Full objects graphs are supported for services method's arguments and return (see provided example in the distribution), including nested collections (List and Map) and heterogeneous collection elements.
Its use is as easy as with GWT (and does not require any generation step thanks to the Objective-J runtime - interpreter step at runtime).

Usage

On the client-side:

JAVASCRIPT:
  1.  
  2. var endPoint = [CP2JavaWSEndPoint
  3. createForURL:@"http://localhost:8080/CP2JavaWSServletTest/CP2JavaWSEndpoint1"];
  4.  
  5. var remoteService = [endPoint proxyForJavaServiceInterface:@"com.cp2javaws.demo.services.IDemoService1" delegate:self sameDomain:true];
  6.  
  7. [remoteService method1:@"arg1StringValue"
  8. andWithArg2:2 andWithArg3:new Date() delegateRespHandler:@selector(manageServiceMethod1Response:) delegateFailHandler:@selector(manageServiceMethod1Fail:)];
  9.  

On the server-side:

Just subclass the provided CP2JavaWSJSONServlet servlet and implement the (abstract) method:

JAVA:
  1.  
  2. protected Object getService(Class serviceInterface)
  3.  

A mapping file (see provided example) has to be put on the server-side for custom objects (maps custom Objective-J objects classname to corresponding Java custom objects classname).

More info

Posted by Dion Almaer at 5:40 am
2 Comments

++++-
4.2 rating from 10 votes

Monday, January 5th, 2009

Special Offer for Ajaxian Readers: TheServerSide Java Symposium

Category: Conferences, Java

Hello Ajaxians!

We're inviting all of the Java developers out there to an event organized by our sister site, TheServerSide.com, the Web's largest enterprise Java community. As a member of Ajaxian, you save an extra $100 off the registration fee with the code AJAXIAN. (Register before January 16 to save a total of $400 and get a free book!)

TheServerSide Java Symposium explores current and emerging trends in enterprise Java and how they apply to your daily work. Choose from over 45 technical sessions on new technologies, best practices and practical tips from some of the brightest minds in the industry, including Rod Johnson, Neal Ford, Scott Davis and 35 Java experts.

Tracks include Frameworks, Architecture, SOA, Language, Tools and Techniques.

Project and spec leads dive into:

  • The latest features of Spring, JSF, Wicket, Tapestry, Google Web Toolkit and more frameworks.
  • New Java language features, such as EJB 3.1, Glassfish and JavaFX
  • Popular open source tools, including Eclipse, Maven, Lucene, soapUI, HtmlUnit for testing SOA, Ajax and RIAs.
  • Expert recommendations on the use of Groovy, Scala and JRuby
  • Building and maintaining a large-scale SOA
  • How to create and consume RESTful Web Services.
  • How and when to use an ESB.
  • Best practices and tools for optimizing performance and scalability.
  • And much more!

View TheServerSide Java Symposium agenda to see all of the sessions being presented. Register now with the code AJAXIAN to save an extra $100 and to get a free book while supplies last.

Posted by tberardi at 3:46 pm
Comment here

+++--
3.1 rating from 9 votes

Friday, December 19th, 2008

DWR 3.0 near final release with RC

Category: Java, JavaScript, Library

Joe Walker and team have announced the first RC for DWR 3.0. We asked Joe to tell us what is new:

DWR now supports:

  • varargs
  • method overloading
  • typed parameters
  • binary file upload/download
  • it has a set of new types it can marshall

DWR will let you use JavaScript to implement Java interfaces (e.g. to register a Listener interface to publish changes to waiting browsers using Reverse Ajax), we now have 3 modes to control resource usage and there is a more scalable Reverse Ajax layer.

There are new integrations with Dojo, TIBCO GI and Aptana Jaxer, and a new DOM manipulation library.

We have special asynchronous servlet support for Tomcat and Glassfish, and our Spring and Guice integrations have been beefed up.

We now support JSONP and JSON-RPC, and there's a whole bunch of etc thrown in for good measure too.

There is a more complete list at Joe's blog, or you can just skip straight to the download page.

Posted by Dion Almaer at 6:02 am
2 Comments

++++-
4.5 rating from 17 votes

Wednesday, December 17th, 2008

OilCan: Grease up your Android browser

Category: Java, JavaScript, Mobile

Jeffrey Sharkey has created OilCan a thin wrapper on top of the WebKit shipping on Android that allows you to install userscripts that allow you to access to Android "Intents".

Intents are very nice abstractions that allow you to access large components and reuse them in different ways. Romain Guy has a nice post on them.

OilCan lets you customize any website by inserting JavaScript to change the website and help it reach into the Android world using intents.

OilCan inserts some powerful buttons into normal websites, and that power comes from Android intents. We didn't write a barcode scanner or the radar app into OilCan, but using intents we can launch those apps with parameters. We can request the Barcode Scanner app to scan something and return the code to us, or launch the Radar app with a specific lat/lon.

Userscripts can do other cool stuff, like hide the navigation columns in Wikipedia to make it easier to view on small screens. This is a proof-of-concept for now, and will probably turn into a binary plugin for the default Browser in the future.

A nice piece from an example shows the intent call out:

JAVASCRIPT:
  1.  
  2. function generate(item) { 
  3.     var helper = document.createElement('input')
  4.     helper.type = 'button'
  5.     helper.value = 'Scan barcode...'
  6.     helper.addEventListener('click', function(event) { 
  7.         // use the intentHelper bridge to fire an intent to Barcode Scanner 
  8.         // it's available in Market, or from http://code.google.com/p/zxing/ 
  9.         var result = window.intentHelper.startActivityForResult(JSON.stringify({ 
  10.             action:'com.google.zxing.client.android.SCAN'
  11.             category:['CATEGORY_DEFAULT'] 
  12.         }))
  13.  
  14.         // parse the result we get back, and read the barcode from the extras 
  15.         result = JSON.parse(result)
  16.         item.value = result['extras']['SCAN_RESULT']
  17.     }, false)
  18.     return helper; 
  19. } 
  20.  

Very cool!

Posted by Dion Almaer at 6:13 am
9 Comments

++++-
4 rating from 5 votes

Tuesday, December 16th, 2008

Interfaces in JavaScript

Category: Java, JavaScript

The UML diagram above is from Matt Prokes as he creates Java-like interfaces for JavaScript.

He has a full example:

An example of an object which requires an implementation of the interface.

JAVASCRIPT:
  1.  
  2. //This code is valid, and the execution will be successful.
  3. function executeInterface1(executeThis){
  4.   var castedIface = executeThis.cast('TestInterface');
  5.   castedIface.testMethod1(1,2,3);
  6. }
  7.  
  8. //This code is valid, but the execution will not be successful.
  9. function executeInterface2(executeThis){
  10.   var castedIface = executeThis.cast('TestInterface');
  11.   castedIface.testMethod2(4,5,6);
  12. }
  13.  

Alright, lets instanciate, the objects and set them to variables. Feel free to type in the variables and take a look, on the firebug window!

JAVASCRIPT:
  1.  
  2. InitedTestObject = new TestObject();
  3. //variable not used in this example, but I thought I would still make it available!
  4. CastedTestInterface = InitedTestObject.cast('TestInterface');
  5.  

Ok, so lets try it out! We wrap it all up in some simple div tags with onclick events.

HTML:
  1.  
  2. onclick="executeInterface1(InitedTestObject)"
  3. onclick="executeInterface2(InitedTestObject)"
  4.  

Posted by Dion Almaer at 12:51 pm
9 Comments

++---
2 rating from 22 votes

Monday, December 1st, 2008

AbstractCanvas: HTML Canvas and Java2D in one fell swoop

Category: Canvas, GWT, Java

Rodrigo Reyes has announced a new project called AbstractCanvas, a GWT project that sits on top of HTML Canvas and Java2D.

The same code can thus run in the browser, or on the server.

You can then write code such as:

JAVA:
  1.  
  2.  VerticalPanel vPanel = new VerticalPanel();
  3.  
  4.  CanvasPanelExt canvas1 = new CanvasPanelExt(300,150);
  5.  
  6.  canvas1.setFillStyle(Color.WHITE);
  7.  canvas1.setGlobalAlpha(1.0);
  8.  canvas1.fillRect(0, 0, canvas1.getCoordWidth(), canvas1.getCoordHeight());
  9.        
  10.  canvas1.addCanvasPainter(new ColorTest()); // <- Note the use of CanvasPainter here
  11.  canvas1.addCanvasPainter(new PathTest());     <- and here
  12.  
  13.  vPanel.add(canvas1);
  14.  

Posted by Dion Almaer at 7:09 am
8 Comments

++++-
4 rating from 15 votes

Friday, October 17th, 2008

Java Plugin 6 Update 10 Production Release

Category: Java

It really is plugin week isn't it. We had Flash and Silverlight, so it was time for Java to pop its head up from the shadows, and that is what happened with the production release of Java 6 Update 10. It has to be one of the worst version names, but a solid plugin release it is! We originally sat down with Ken Russell to talk about this version on October 18th, 2007.

Cote has some nice coverage via his interview with Danny Coward:

When I was in his neck of the woods last, I got the chance to talk with Sun’s Danny Coward, the Chief Architect of Sun’s Client Software (that is, Java SE, Java ME, JavaFX and JavaCard), about Java 6 Update 10. That seems like kind of a narrow topic to speak to, but as Danny and I discuss, it’s a big release for Sun’s RIA and client-side (re-)push.

Along those lines, we spend a lot of time detailing the re-written plugin that’s used for Java applets and JavaFX, the improved installer and update experience, and other client side features like one of the new GUI look-n-feels, Nimbus.

Update 10 is available now.

I have to admit to not "getting" JavaFX, but the Java plugin features are great to see, and it is nice to see the final release.

Posted by Dion Almaer at 12:01 am
5 Comments

++++-
4 rating from 36 votes

Friday, August 29th, 2008

GWT 1.5 final release is shipped and out the door

Category: GWT, Google, Java, Library

I have seen the GWT team working very hard indeed on GWT 1.5, and they must be very happy to see the final release shipped and complete:

GWT 1.5 delivers what we think are an impressive number of improvements, about four hundred issues if you're counting. We're also happy that one of those is issue 168, our most-requested feature, Support for Java 5.

The high level new feature sets are:

  • Java 5 language support and enhanced JRE emulation
  • Performance optimizations and easier JavaScript interop
  • Prettier widgets, better DOM, accessibility, and bi-di

You can see a lot of this at work in the showcase area. There you will see all of the widgets and examples that come out of the box, and the community has developed even more for you. In particular, Ray Cromwell has some great real world examples that he shares in his book and talk.

Download GWT and take a look.

Posted by Dion Almaer at 10:51 am
2 Comments

+++--
3.9 rating from 26 votes

Monday, August 25th, 2008

Putting together GWT and Spring

Category: Java

Dave Kuhn has put together a comprehensive guide to piecing together GWT and Spring, a nice recipe for the Java heads among you.

Dave starts out by detailing why you would want to do this, and how it changes the architecture of your application.

He then gets to a tutorial that has you creating the project correctly, and configuring an actual service. Once you are done with the code, you need to setup hosted mode to point to a nice external tom cat via:

-out www GwtWisdom/GwtWisdom.html
-noserver
-port 8080

Posted by Dion Almaer at 7:51 am
2 Comments

++++-
4.1 rating from 21 votes

Next Page »