Petition Apple to contribute Mac Java to OpenJDK
Oct 25, 2010
Guyub adalah perusahaan TI berpusat di Palembang dengan fokus pada F/OSS Produk-produk >> Layanan-layanan >>
Oct 17, 2010
Google maps was a useful hit from the moment it went on line. Since then thousands of web pages have added map capability to their sites, courtesy of Google. Let me illustrate how you can add Google maps to your Java application.
Background Getting It After the question mark, append all of the details you wish to be included in the map, separated by ampersand (&) symbols. For example: This requests a road map centering on the Brooklyn Bridge, in New York City, at zoom level 14, 512×512 pixels in size. There’s a very rich collection of options for specifying and decorating maps, Google has very helpfully made a highly detailed page explaining them all.
As I hope you’ve reasonably guessed; the http request dutifully returns an image of the map requested. That’s all there is to it!
Using It The variable map now has the image, ready for presentation! Remarkably easy wasn’t it? That’s all it takes, and you can enjoy the full functionality of Google maps in any Java application.
Want More? Enjoy,
Google furnishes its maps via a simple REST request. Does this mean you need to add some fancy REST framework to your application? Not at all! Java provides all you need right in the standard libraries, and it is very easy to do. (that’s part of the real elegance of REST)
To request a map, you start with the following URL:http://maps.google.com/maps/api/staticmap?
http://maps.google.com/maps/api/staticmap?center=Brooklyn+Bridge,New+York,NY&
zoom=14&size=512x512&maptype=roadmap
Happily, Java provides all the resources you need to use this great Google feature right in the Standard Edition. Simply create a java.net.URLConnection, request the content, and generate the map image. If you’ve not done this before, fear not, as Java makes it very easy to do, it looks a bit like this:
URLConnection con = new URL("http://maps...").openConnection();
InputStream is = con.getInputStream();
byte bytes[] = new byte[con.getContentLength()];
is.read(bytes);
is.close();
Toolkit tk = getToolkit();
map = tk.createImage(bytes);
tk.prepareImage(map, -1, -1, null);
Of course I’m not going to leave you hanging like that!
I’ve written a complete free runnable GoogleMap Java component for you, it’s less than one page of code. Try it out and let me know what you think.
Oct 14, 2010
In my last blog entry, I described VideoSharing which is an application that uses Web sockets to remote UI events and enable participants to control HTML5 video players remotely. Today, I’d like to share with you a similar type of collaboration application, but this time one that uses other HTML5 features: namely, 2D canvases and client SQL databases. The name of this application is BoardMirror. Rather than sharing a video object, like in VideoSharing, BoardMirror shares a canvas object and lets participants draw figures on it. For the sake of simplicity, only two figures can be drawn on a canvas: rectangles and circles. These figures are drawn in a random location inside the canvas and using a random color. Here is a screenshot of the application: The mirror or collaboration part of the application is the result of copying these figures in all the other canvases that are connected to the server. And, of course, we use Web sockets for this purpose. A Web socket is nothing more than a socket connection that can be established between a (modern) Web browser and a Web container. It provides a low-latency, bi-directional communication parallel to the HTTP channel. It is Ajax/Comet on steroids. In addition, the BoardMirror application has the ability to store your work of art in a local SQL database in the browser. This is done using one of the new APIs in HTML5. In fact, HTML5 has two options for storing data on the client side: Web Storage and Web SQL Databases. The former is implemented by most browsers and can store name-value pairs; the latter, as suggested by its name, gives you full SQL storage but it’s only implement in some browsers. Let me start describing the canvas and 2D APIs first. As in the VideoSharing application, we use a JSF facelet to define our main page: where the h5:canvas element is defined in the same way as h5:video in the VideoSharing blog. What follows is a JavaScript method that draws a rectangle, sends the rectangle to be drawn remotely and stores the rectangle in a local data structure so that it can saved in a local database, if so requested by the user. The code that draws the rectangle should be self explanatory, yet another 2D API! The last three lines of code are there to: create a shape object, send the shape over the network and store the shape in an array, respectively. The network object is initialized in the same way as in the VideoSharing application; only it’s onmessage handler is different: Since a canvas can be remotely cleared, there’s a special clear shape type that triggers such a remote event. For all the other shapes (real shapes, that is), the mirrorShape() method is called. This method simply draws the shape in the local canvas (without resending the shape over the network again!). As stated above, this application also supports storing your canvas in a local database. This is done by storing all the shapes in JSON format. The database logic is implemented in the object returned by the database function shown next. In the initialize() method, the SQL database is opened and a table is created to store the shapes. If the table exists, an error will be ignored since no error handler is provided in the call to tx.executeSql(). The load() method runs a select query without any parameters (notice the "[]") and provides a results handler that parses and stores the shape in the array. The save() method clears the table and then inserts the shape one by one into the database. Note how parameters are passed to fill in the value placeholders denoted by "?" in the SQL string. This should be familiar to anyone that has written JDBC code before. One interesting aspect of the SQL API is that, following a pattern that is common in Javascript, all operations are asynchronous. This is why functions are passed to methods like db.transaction() and tx.executeSql(). However, the order in which SQL statements are executed follows the execution order of the calls to tx.executeSql(). That is, statements are always queued and run in order —and this is why methods like save() above work. The Web sockets code in Glassfish that supports this application is identical to that in the VideoSharing application. For more information, the reader is referred to the VideoSharing screencast or to the attached source code bundle. Please note that Web sockets are not enabled by default in Glassfish. To enable them you must execute the following single-line command on your domain:

<html ...>
...
<h:body>
<h5:canvas width="600" height="400"/>
<h:outputScript library="js" name="json2.js" target="head"/>
<h:outputScript library="js" name="app.js" target="head"/>
<br/>
<input type="button" value="Rectangle" onclick="APP.drawRectangle()"/>
<input type="button" value="Circle" onclick="APP.drawCircle()"/>
<input type="button" value="Clear" onclick="APP.clearCanvas(true)"/>
<input type="button" value="Load" onclick="APP.loadCanvas()"/>
<input type="button" value="Save" onclick="APP.saveCanvas()"/>
</h:body>
<html>
drawRectangle: function() {
// Get access to canvas and draw rectangle
var canvas = this.getCanvas();
var ctx = canvas.getContext('2d');
ctx.fillStyle = this.random.color();
var width = this.random.number(40, 100);
var height = this.random.number(40, 100);
var x = this.random.number(0, canvas.width - width);
var y = this.random.number(0, canvas.height - height);
ctx.fillRect(x, y, width, height);
// Mirror rectangle via web sockets and store in array
var shape = {type: "rectangle", x: x, y: y, width: width,
height: height, color: ctx.fillStyle};
this.network.send(JSON.stringify(shape));
this.shapes[this.shapes.length] = shape;
},
websocket.onmessage = function (evt) {
var shape = JSON.parse(evt.data);
if (shape.type == "clear") {
APP.clearCanvas(false);
} else {
APP.mirrorShape(shape, false);
}
};
var database = function (db) {
return {
error: function (err) {
alert(err.message);
},
initialize: function() {
if (window.openDatabase) {
db = openDatabase('shapes', '1.0', 'All Shapes', 64 * 1024);
db.transaction(
function (tx) {
tx.executeSql('CREATE TABLE shapes (id UNIQUE, shape STRING)')
});
this.load();
} else {
alert("Your browser does not support SQL databases");
}
},
load: function() {
db.transaction(function (tx) {
tx.executeSql('SELECT * FROM shapes',
[],
function (tx, results) {
for (var i = 0; i < results.rows.length; i++) {
var shape = JSON.parse(results.rows.item(i).shape);
APP.shapes[i] = shape;
}
APP.refreshCanvas();
},
this.error)
} );
},
save: function() {
db.transaction(function (tx) {
tx.executeSql("DELETE FROM shapes");
for (var i = 0; i < APP.shapes.length; i++) {
tx.executeSql('INSERT INTO shapes (id, shape) VALUES (?, ?)',
[i, JSON.stringify(APP.shapes[i])], this.error);
}
alert("Canvas has been saved into a local database");
});
}
}
};
asadmin set configs.config.server-config.network-config.protocols.protocol.http-listener-1.http.
websockets-support-enabled=true
| Attachment | Size |
|---|---|
| boardmirror.jpg | 132 KB |
| BoardMirror.zip | 27.12 KB |
Oct 13, 2010
A good starting point for thinking about the consequences of the Oracle + IBM deal is in the blog of Gianugo Rabellino: … I will readily admit there is a positive side in IBM ditching Harmony and joining OpenJDK, as the world is now closer to enjoy a strong Java platform. The problem is the price tag. With IBM surrendering to the Oracle bully, the Java Community Process is now as credible as Weekly World News, and basically nobody is safe. The spin pros have been busy focusing on a strengthened, renewed Java effort, and they conveniently (or should I say pragmatically?) forgot to mention how dangerous it is to be under the illusion that the JCP is a neutral and cooperative body producing Open Source friendly specs when the truth is Oracle can and do whatever they want, including breaching the JSPA and getting away with it. Or play puppet master even with mighty IBM. I wish all my FSF friends will soon recover from the initial excitement for a GPLed Java and realize how, really, the party is over and we have much less freedom than before. And maybe a better JVM with no competitors – but is it worth the price? My point. First, I’m sad that Harmony is probably going to die. Having one more independent implementation of Java, under a different license, was a plus for the community. In any case, things haven’t changed with the Oracle management: the no-TCK policy for Harmony was started under Sun and, in my opinion, it was not something unexpected, as they choose the GPL license that guarantees the control of the product by means of the original creator (note that I’m not criticizing Sun’s approach: I understand that from the corporate point of view it could have been a good move, the problem here is harmonizing the corporate’s and the community’s needs). I disagree with Gianugo when it says that "Java is not free". "Freedom" to me is a shades-of-gray concept, not black and white. Definitely, we’re less free if Harmony goes; but we’re still free to fork OpenJDK, if we want. While full light hasn’t been shed on the scene yet, my opinion is that forking the GPLv2 OpenJDK would save you from any patent litigation. So, my rephrasing of Gianugo’s point is that we have to understand how much freedom we have and whether we’re free enough with the single choices: OpenJDK or an OpenJDK fork. At the moment, I don’t know, but I suppose this situation gives use some decent protection. We need to think more about that. Let’s remember that "freedom to fork" is for us a way to protect ourselves from a possible future Java evolution that we don’t like. So, to decide whether Java is free enough or not, we should start with writing down what we’d like to do and protect from. A good starting point are the four freedoms defined by the FSF: So, in future discussions, I’d really like to see "free" with a quantification, rather than an absolute quality. A final consideration from me. There’s some discussion about whether Harmony could survive after being abandoned by IBM or not. Stephen Colebourne (who’s supposed to know what he’s talking about) looks pessimistic: While never solely an IBM project, I would expect this to effectively mean the termination of the Harmony project.
Other commenters disagree and think that Google could step in, given its interest in Harmony as the basis for Android (even though I have still to understand how, in 2010, the two projects are really related). I feel Google is really alone after the IBM move (I suppose that other corporates will jump on the Oracle + IBM wagon), but they have got large shoulders. Now, my point. Let’s suppose that there’s no Oracle lawsuit against Android (hence, implicitly, against Harmony), or that Oracle loses the lawsuit. Let’s suppose at a certain point the community really breaks with Oracle and moves away from Java, deciding to create a *ava fork that it’s not based on the OpenJDK because, for some reason, it reveals not to be free enough. It would be possible to resume work on Harmony: the fact that you don’t have a TCK for it just means you can’t call it Java™. But the community, by testing its projects on it, would be able to determine whether it’s really Java compatible and a viable escape way. In case of a final break with the Java steward, nobody would be much fond of the Java name, being the effectiveness of the solution the only important point. Now, reading "never solely an IBM project, I’d expect this to effectively mean the termination", or even optimistic people seeing a future to Harmony but only bound to Google stepping in, reinforces my idea that the community is not able to run a *VM technology alone, without the support of a major corporate. Isn’t this the real problem, indeed, beyond any TCK or legal disputation?
PS As a further food for brain, I’ve learnt that Shark has been finally merged to OpenJDK 7. Shark is an IcedTea contribution, allowing to use the LLVM JIT to run Java bytecode. It has been introduced to extend the supported microprocessor architectures and simplify the porting process. It could be an escape lane in case the community decides to be free to choose a different *VM than the one coming from Oracle or IBM. LLVM is developed in the open (BSD license) by the University of Illinois, but my understanding is that Apple’s funding and contributions are fundamental for this project. This seems to confirm that for a successful *VM technology to exist, you need a large corporate. And the problem remains.
Sep 21, 2010
So, what will the Monday night Oracle Open World / JavaOne / Oracle Develop keynote tell us? Intel and Thomas Kurian will provide the answer, which I’m watching on the Oracle Technology Network Live videostream.
So, I work in an Oracle/Sun data center. I guess you could say I’m biased, because we made that decision and it has turned out great for us. But, we are building a new data center, a next-generation data center. So, I’m really interested in what the future holds.
Intel is about to speak. I loved my tenure as community manager for ThreadingBuildingBlocks.org. Intel is superb! They understand the interactions between hardware and software. Bottlenecks are ultimately hardware related (the hardware executes as many instructions as it can in a given period of time); yet, ineffiecient software can leave too much hardware sitting around doing nothing; or, it can ask the hardware to repeat solutions to problems that have already been solved, but which weren’t saved.
Intel designs its hardware such that it will deliver ultimate performance for software developers who have some understanding of the implications that a line of code has on hardware.
Now the conversation turns to Java, the collaboration between Intel and Oracle with respect to Java, with an invitation to visit Intel Booth 509 at JavaOne. And the Intel presentation ends.
The focus now turns to Java, with Oracle’s Thomas Kurian speaking. Thomas highlighted Project Coin, with its improved type reference inference, try-with-resource blocks; Project Lambda (closures); and Project Jigsaw (the modular Java platform).
The next focus is multi-core processors, large memories, fast networks. You know that I belive this is the future, and must be addressed. Also, support for additional languages (Scala, for example) will be added. This is the .NET model (and I won’t argue who invented it first, Sun or Microsoft – though, to me, .NET was a response to Java)…
There will be new OpenJDK releases in 2011 and 2012.
The next discussion is on the client side. HTML5 is a key focus, along with native applications. JavaFX, JavaScript, Java 2D and 3D are considered key. JavaFX is highlighted as being a key element in the Java client arena going forward. Open Source is highlighted, along with support for large datasets, and flexibility with respect to images and other data types.
Oracle’s view is that all future browsers will run HTML5. Which means that Java and Javascript and modern graphic engines will be deployable to provide new Web experiences (as well as desktop experiences, I’d think).
I like what I’m hearing, so far!
Next is a demo of what Java is able to accomplish today on the client side. A JavaFX cup, followed by a game screen… an array of screens… fancy graphics/visualizations… quite fancy. All done vector graphics, no images. I think you have to see it to comprehend it. A real lot is possible using vector graphics and Java.
Thomas talked about the mobile vision: Project Mobile.Next. This will involve updates to the Java language, the VM, libraries, packages, and APIs. The goal is to enable Java support for new devices and new markets, including smartphones and many other mobile devices. Java Card and mobile payments were featured.
Bioware was the next focus, in a presentation of the “StarWars: The Old Republic” game, which runs on GlassFish. The video was spectacular, and it seems it’s all developed using Java.
In conclusion, Thomas said Oracle is committed to giving developers the world’s best programming platform on the desktop side, on the mobile side, and on the server side. And he announced the upcoming non-US JavaOnes. Then Olympic Champion Apollo Ohno came out, and said he was excited to be at JavaOne. I really liked watching him at recent Olympics, and it’s a thrill to see him at JavaOne! He said often people tell him “You look a lot like Apollo Ohno” and he says “I hear that a lot!”
So, what will the Monday night Oracle Open World / JavaOne / Oracle Develop keynote tell us? Intel and Thomas Kurian will provide the answer, which I’m watching on the Oracle Technology Network Live videostream
I myself am pleased by Oracle’s vision for Java, as presented at JavaOne 2010 thus far. What do you think?
Justin Kestelyn points us to the JavaOne photostream in Let The Photos Commence:
Yep, we’re onsite in our JavaOne home for the week, the Mason St. tent, and documentation of the goings-on around us has already begun… Stay tuned to this photostream for more virtual experiences!
On the JavaOne Conference Blog, Janice Heiss posted Rock Stars Tony Printezis and Raghavan Srinivas Chime in on the Future of Java:
I caught up with two JavaOne Rock Stars, Tony Printezis of Oracle and Raghavan Srinivas, a Java evangelist known for keeping his finger to the wind, to get their take on Java and JavaOne. I asked Printezis, a leading expert on Garbage Collection and Java about this year’s JavaOne…
R. Tyler Ballance of Hudson Labs, who’s blogging at JavaOne, reported on the Pre-JavaOne Hudson Meetup Redux:
Yesterday Digg was kind enough to host and “sponsor” (read: free drinks and pizza!) a Hudson meetup at their offices in San Francisco. While Digg has been the source of some controversy and press due to their recent redesign and corporate shake-ups, as far as the Hudson community goes they’ve been largely responsible for a great case study on continuous deployment using Hudson and Gerrit…
Dustin Marx is posting JavaOne 2010: JDK 7 and Java SE 7 as he attends the JavaOne 2010: JDK 7 and Java SE 7 session at JavaOne:
For my first real JavaOne 2010 session, I am attending JavaOne 2010: JDK 7 and Java SE 7 in the large Hilton San Francisco Grand Ballroom A/B. I normally write a blog post in its entirety before submitting it, but in this case I am going to continually submit this same post with updates as the presentation continues. In other words, I will be updating this same post throughout the presentation…
Our current java.net poll asks What’s your view of Java on the desktop? Voting will be end soon.
Subscriptions and Archives: You can subscribe to this blog using the java.net Editor’s Blog Feed. You can also subscribe to the Java Today RSS feed and the java.net blogs feed. You can find historical archives of what has appeared the front page of java.net in the java.net home page archive.
– Kevin Farnham
“The future of Java is not about Oracle, it’s about you the developers, and what you make Java become” — or something like that was Thomas’s last statement.
Java Today
Poll
Twitter: @kevin_farnham
Sep 18, 2010
Sep 17, 2010
code-recommenders – IDE 2.0: Bringing Collective Intelligence into Software Development java-toto – sweepstake application
Most Active Projects
anyedittools – AnyEdit plugin adds several new tools to the context menu of text based Eclipse editors, to Eclipse main menu and editor toolbar
birt-functions-lib – A collection of BIRT Aggregate and Script Function Extensions for use in your project
birt-controls-lib – A collection of BIRT ReportItems created through the ReportItem extension point.
wascana – Wascana Eclipse C/C++ IDE for Windows Developers
ostool – Central metadata repository for unstructured data supports records and knowledge management for small and medium-sized organisations.
onotoa – Onotoa is a visual editor for the Topic Maps Constraint Language.New Projects
multiproperties – MultiProperties is an Eclipse editor for multiple Java properties files editing simultaneously
splendor023 – splendor023
mc920-reconhecimento-facial – Realce da face
smartedu1 – Education management
smartedu – Education management
hypeerweb – BYU CS 340 Project
Sep 12, 2010
Scala is an object oriented and a functional programming language. If you already know Java or C# you will find Scala an easy to learn and a powerful one. Most of the new features that were added in C# (comparing with Java) exist as well, and apart of enjoying the power of OOP you will also get to enjoy the power of Functional Programming. There are many advantages for using Scala. However, the one I find as the most interesting one from a business perspective is the ability to compile code written in Scala either into intermediate language code or into java byte code. Companies, that maintain two versions for their products, one for the .NET platform and one for the Java EE platform, can use Scala for maintaining the core modules of their products in one version. The Scala version. Given the scalability related unique adavantages of Scala (comparing with Java and .NET), doing so can also assist with implementing the required changes set by the dynamic business environment in which we operate.
Sep 11, 2010
Spring by default uses the class DefaultSessionAttributeStore to store and retrieve the command objects from the session based upon the session attribute name only. This is what causes the command objects to be stomped on by multiple requests within the same session.
This is a known issue and a JIRA ticket has been created that will address this in version 3.1M1.
To address this issue until the fix is incorporated into Spring, I created the following solution:
I created the a class that implements the SessionAttributeStore interface. This class stores and retrieves the session level command objects based upon a unique (conversation id) that is automatically generated when the command object is stored on the session. So when you do a get request with a controller that has session attributes and you assign your command object to the model map, the storeAttribute method will be invoked and it will generate a unique conversation id (System.currTimeInMillis()) and append this to the attribute name (your command object name) and store it on the session as well as set the conversation id as a request attribute so that the view that is displayed can post back the conversation that it will be involved in. So all you have to do is add a hidden input field in your form that will post back the conversation id that it is in and the controller will issue a retrieveAttribute method and based upon the incoming conversation id will retrieve the correct command object from the session. I created a simple tag library that will create a hidden input field for you.
It is pretty simple to setup, basically you do the following:
In your dispatcher-servlet.xml file you define the class that you want to do the storing and retrieving of command objects from the session
<bean id="sessionConversationAttributeStore" class="com.marty.support.SessionConversationAttributeStore"> <property name="numConversationsToKeep" value="10"/></bean>
Then you tell the AnnotationMethodHandlerAdapter class that you want to use a custom sessionAttributeStore:
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"> <property name="webBindingInitializer"> <bean class="org.springframework.web.bind.support.ConfigurableWebBindingInitializer"> <property name="conversionService" ref="conversionService" /> </bean> </property> <property name="sessionAttributeStore"> <ref bean="sessionConversationAttributeStore"/> </property> </bean>
Finally you add the following tag library call inside your forms that use session model attributes:
<sessionConversation:insertSessionConversationId attributeName="<your command name here>"/>
Here is a link to a sample application that shows how to use the custom SessionAttributeStore along with the source code for the SessionConversationAttributeStore class and the SessionConversationIdTag tag library.
Hopefully someone else will find this helpful.
Marty