background preloader

Java

Facebook Twitter

Collections - Features you want with the collections you need. History of Eclipse Collections The origin of Eclipse Collections was started off as a collections framework named Caramel at Goldman Sachs in 2004. Since then the framework has evolved, and in 2012, it was open sourced to GitHub as a project called GS Collections. GS Collections has been presented at number of conferences including JVM Summit in 2012 and JavaOne in 2014. A performance comparison between the parallel lazy implementations of Java 8, Scala and GS Collections was presented at QCon New York in 2014. Also articles about GS Collections (Part1 / Part2) have published on InfoQ.com showing some of the capabilities of the collections framework through examples, and also interviews to the creator of GS Collections. Over the years, around 40 or so developers from the same company have contributed to the collections framework. To maximize the best nature of open source project, GS Collections has been migrated to the Eclipse Foundation, re-branded as Eclipse Collections in 2015.

Fastutil. Trove4j / trove.

Java bugs

Java 8. Build. Java Secret: Using an enum to build a State machine. Overview The enum in Java is more powerful than many other languages which can lead to surprising uses. In this article, I outline some the individual features of enum in Java, and put them together to form a state machine. Enum for Singleton and Utility class You can use an enum as a Singleton or Utility very simply. Enum to implement an interface You can also implement an interface in an enum.

Each Enum Instance a different sub-class You can override the behaviour of an instance. This effectively give the instance a different sub-class of the enum with its own implementation. Using an enum as a state machine What you can do with all these techniques is to create a enum based statement. In this short example, a parser state machine processes raw XML from a ByteBuffer. Using this approach it is possible to write an XML parser which can process packets in sub 10 micro-seconds. Reference: Java Secret: Using an enum to build a State machine from our JCG partner Peter Lawrey at the Vanilla Java. Programmatically Restart a Java Application. We Recommend These Resources Today I'll talk about a famous problem : restarting a Java application. It is especially useful when changing the language of a GUI application, so that we need to restart it to reload the internationalized messages in the new language.

Some look and feel also require to relaunch the application to be properly applied. A quick Google search give plenty answers using a simple : 1.Runtime.getRuntime().exec("java -jar myApp.jar"); 2.System.exit(0); This indeed basically works, but this answer that does not convince me for several reasons :1) What about VM and program arguments ? Overall, something that works fine for some test, sandbox use, but not a generic and elegant way in my humble opinion.

Ok, so my purpose here is to implement a method : 1.public static void restartApplication(Runnable runBeforeRestart) throws IOException { Let's start by looking at each point and find a way to answer them in an elegant way (let's say the most elegant way that I found). 2. 15. Updating Java EE in Production: A Report in Three Acts Including a Foreword and an Afterword | ZeroTurnaround.com.

Foreword A few weeks ago I ran a survey asking a dozen or so questions about Java EE production update. I’d like to thank the 607 individuals who took some time from their busy life to help me out. Today, I’ll return the favor by analyzing the resulting data for your pleasure. If for some reason you don’t trust me, feel free to check the calculations on the original data in this spreadsheet. I’m sorry I couldn’t do this before, but life was too busy to do a proper analysis in the meantime.

As it is, I’m writing these words from the CDG airport in Paris and will likely finish the article in the Porto-Lisbon train (or as it turned out in the Lisbon-Porto train). Act I: The Pool Running surveys is always a tricky business. One of the survey questions was “What industry are the applications you’re working on for?” Another question concerned the size of deployment: “About how many servers/instances do you have in production?”.

Act II: Redeploys Considered Broken? Act III: The Update Process. Fork-Join Development in Java SE. Edward Harned (eh at coopsoft dot com) Senior Developer, Cooperative Software Systems, Inc. February, 2010 [updated June, 2013]Serbo-Croatian translation on June, 2013.What is Fork-Join? Think of a fork in the road where each path eventually comes back together — joins.Fork-Join breaks an application into several parts for parallel processing and joins the results at the end.Figure 1: Fork-Join Structure Let’s say we have an array of one thousand numbers. We need to do a procedure on each of these numbers and add the total.Listing 1: Array ProcessingIf the procedure takes one second (wall-clock time) to complete, then it is going to take one thousand seconds (over 16½ minutes) to complete this task.Fork-Join couldseparate (fork) the large array into ten arrays of one hundred elements each,processes each array on a separate CPU, andjoin the results when finished.That would take one hundred seconds (just over 1½ minutes), one tenth of the original time.

Limit Contention Articles: Other: Introducing Chronon: The Time Travelling Debugger for Java. Last week I read an announcement about Chronon, a time travelling debugger. It sounds very appealling - if you're like me, you've often missed that spot where you should have had a breakpoint. Another common issue is reproducing bugs that happened out in the field. Could this tool be the solution to all your problems? I spoke with Prashant Deva, founder and CEO of Chronon, to find out more. DZone: Could you introduce Chronon? Prashant: Chronon is a revolutionary new technology that consists of: A 'flight data recorder' for Java programs which can record every line of code executed inside a program and save it to a file on the disk.

Chronon marks the begining of the end of 'Non-Reproducible bugs'. DZone: Has anyone tried to solve this before? Prashant: There has hardly been any actual real world effort which has come anywhere close to Chronon.The only research we could find was some papers in the academia and even that was pretty useless to us.

DZone: How is this implemented? Sebastian Kübeck's Weblog. Does Java Have to be Extended? There is a lot of discussion in the Java community which language features should be added to the Java language and how they should be integrated. What seems to be missing is a discussion about the question if Java needs to be extended at all. Moreover, there should be a discussion about language features that have been added to Java and C# in the past and how they improved our productivity and the quality of our programs. Some time ago, I once again stumbled over Edsger Dijkstra's famous paper The Humble Programmer.

Especially over the following paragraph: Finally, although the subject is not a pleasant one, I must mention PL/1, a programming language for which the defining documentation is of a frightening size and complexity. So haven't we learned anything in the last 30 years? Honestly, the humble blogger does not have the answers to all those questions but I think they should be asked and discussed before Java shares the fate of PL/1, should they? Java Performance Tuning, Profiling, and Memory Management | Java. Java application performance is an abstract word until you face its real implications. It may vary depending on your interpretation of the word 'performance'. This article is meant to give the developer a perspective of the various aspects of the JVM internals, the controls and switches that can be altered to optimal effects that suit your application.

There is no single size that can fits all. You need to customize to suit your application. You may be facing one of the issues listed below: The dreaded java.lang.OutOfMemory ErrorYour application is literally crawling. Before we take the plunge into solving the issues, we first need to understand some of the theory behind the issues. Theory What does the JVM do? Executes CodeManages Memory This includes allocating memory from the OS, managing Java allocation including heap compaction, and removal of garbaged objects Besides the above, the JVM also does stuff like managing monitors. Very Basic Java Theory 1. Infant mortality in Java JVM flavors. Better Java Web Frameworks. I have been doing web application framework development for a long time.

In my first experience, we developed a “Web Application Framework“, to ease development so that even a business user could write an application. As the years passed, I never saw any business user writing applications because of the fact that this job belongs to programmers. Today some 4GL or DSL tools are still on the search of the same promise. Before writing our own framework, we had used WebObjects development tools, for Java web development.

It was a very good platform that allowed front-end GUI development from a GUI editor with a component model. Every web element can be used as a component and it had events like “clicked”, and click handler Java code can be added with double-click in GUI editor. One disadvantage was portability that you were bound to this platform and its Application Server. Web Application Frameworks meet the web application requirements. Choosing A Java Web Framework: A Comparison. Akuma: Embeddable daemonization library - Mark Thomas: Tomcat 7 & Servlet 3. Threading lightly, Part 2: Reducing contention. When we say a program is "too slow," we are generally referring to one of two performance attributes -- latency or scalability. Latency describes how long it takes for a given task to complete, whereas scalability describes how a program's performance varies under increasing load or given increased computing resources.

A high degree of contention is bad for both latency and scalability. Why contention is such a problem Contended synchronizations are slow because they involve multiple thread switches and system calls. When multiple threads contend for the same monitor, the JVM has to maintain a queue of threads waiting for that monitor (and this queue must be synchronized across processors), which means more time spent in the JVM or OS code and less time spent in your program code.

Moreover, contention impairs scalability because it forces the scheduler to serialize operations, even if a free processor is available. Back to top Technique 1: Get in, get out Listing 1. Listing 2. Listing 3. Fallacies of Distributed Computing - Wikipedia, the free encyclo. The Fallacies of Distributed Computing are a set of assumptions that L.

Peter Deutsch and others at Sun Microsystems (now Oracle Corporation) originally asserted programmers new to distributed applications invariably make. These assumptions ultimately prove false, resulting either in the failure of the system, a substantial reduction in system scope, or in large, unplanned expenses required to redesign the system to meet its original goals. [citation needed] The fallacies[edit] The fallacies are summarized below:[1] Effects of the fallacies[edit] History[edit] See also[edit] References[edit] External links[edit] Blog Xebia France - Chroniques de la performance : J’ai été, il y a peu, confronté à un problème de performances que l’on peut qualifier d’intéressant – dans la bouche d’un expert technique, ce mot a généralement tendance à provoquer une bouffée de panique chez les plus chevronnés des managers.

Je vous explique. Le programme consiste à appliquer massivement un traitement identique à un volume important de données – bref, c’est un batch. Objectif opérationnel : assurer la capacité du système à traiter 50000 dossiers par heure. L’architecture d’exécution de ce batch est relativement classique : un contrôleur est chargé d’obtenir auprès d’un service métier une liste de dossiers à traiter, de segmenter cette liste en lots, puis de soumettre les lots à un pool de threads qui vont réaliser les traitements en parallèle – chaque lot est traité dans une transaction distincte.

Le traitement unitaire d’un dossier est relativement long, de l’ordre de 2 secondes ; les lots sont donc petits – 4 dossiers – pour limiter la durée des transactions. Bien.

Java bookmarks

Tomcat. Annotation processing. JVM tuning. Proposed Asynchronous Servlet API. With Java NIO, you can theoretically manage 10,000 read, write and read/write connections with a total of one thread. Yes, but it's not clear to me how you can manage this under the Servlet API. With a custom non-servlet server, then sure, assuming the request processing for each channel is lightweight enough.

Note that the Servlet API extensions that Jetty has implemented could be standardised so that standard Servlets could work nicely with an NIO server efficiently like Jetty already has done. See the title of this thread :) But if I have an NIO front end on the server and it calls a generic servlet, the servlet is going to consume a thread and can conceptually "do anything it wants", like block on another server resource (say, a JMS synchronous getMessage() call, or a particularly long SQL query).Basically, the problem I see is I can't see the advantages that a NIO based servlet container can provide, save serving up static resources. EU Rejects Snoracle - Larry Vows to Fight!

Oracle and the EU are escalating their legal battle over the Sun acquisition. The EU took the first step towards blocking the merger Monday with a formal Statement of Objections. Oracle immediately responded with a statement of its own, saying the EU has a "profound misunderstanding" about competition in the database market and "open source dynamics". Sources expected the objection to come soon after Oracle, led by CEO, Larry Ellison, refused to give up the MySQL database in the merger. The company says it will "vigorously oppose" the EU's Statement of Objections. Oracle's release pointedly states "It is well understood by those knowledgeable about open source software that because MySQL is open source, it cannot be controlled by anyone.

That is the whole point of open source. " The Statement of Objections confirms previous reports indicating that MySQL is the only barrier standing in the way of a Sun-Oracle merger. Java Performance Tuning, Profiling, and Memory Management | Java. Jai: Java Advanced Imaging Binary Builds. Jai-imageio: Java Advanced Imaging Image I/O Tools Binary Builds. Stephen Colebourne's Weblog. Joe Darcy has opened up a call for methods to add to the core JDK 7 lang/util package. The idea is to add methods that are "commonly-written utility methods". JDK 7 utility methods There is lots of prior art in the field of general utility method libraries for Java. Perhaps the best known is Apache Commons Lang.

Lets choose some methods (other than string utilities) that might be appropriate for the JDK from ObjectUtils. 1) Null-safe equals check. boolean Objects.equals(Object object1, Object object2) Returns true if both are null, or both are non-null and equal. 2) Null-safe hash code. int Objects.hashCode(Object object) Returns the hash code of the object, or zero if the object is null. 3) Null-safe toString. 4) Null-safe toString with specified default. 5) Null-safe object defaulting. 6) Get maximum and minimum. These would appear to be the obvious methods to add to an Objects utility class. The following are missing methods on Integer/Long: 8) Get common environment variables. Sebastian K beck's Weblog. Sebastian K beck's Weblog. Joseph D. Darcy's Sun Weblog. Strings in switch and closures. Interview: Wilfred Springer on Bit Syntax for Java. Java. JavaFX, You've Come A Long Way.

Finding Out Where Your Class Files Are. Java vs. C Performance....Again. | Azul Systems: Run, Scale, Sim. HtmlUnit: A Quick Introduction. Xuggler.

Eclipse

Artistic Style - Index.