Feed aggregator

Prometheus With Java EE and MicroProfile Metrics [Video]

Javalobby Syndicated Feed - Wed, 07-Feb-18 04:01

I have recorded a video in which I show how to realize business metrics by integrating Prometheus using Java EE and MicroProfile Metrics on OpenLiberty.

Similar to a previous video that used the Prometheus Java API, we’ll expose “coffee business metrics” from a Java Enterprise application.

Categories: Java

Learning to Use the GraalVM

Javalobby Syndicated Feed - Wed, 07-Feb-18 01:01

In the post "Truffle served in a Holy Graal: Graal and Truffle for polyglot language interpretation on the JVM," we got a brief introduction and a bit of deep dive into Graal, Truffle, and some of the concepts around it. But no technology is fun without diving deep into its practicality, otherwise it's like Theoretical Physics or Pure Maths — abstract for some, boring for others (sorry, the last part was just me ranting).

In this post, we will be taking a look into the GraalVM, by installing it, comparing SDK differences and looking at a some of the examples that illustrate how different languages can be compiled and run on the GraalVM, and also how they can be run in the same context and, finally, natively (more performant).

Categories: Java

Secure Your Vert.x Server With Single Sign-On From Okta

Javalobby Syndicated Feed - Tue, 06-Feb-18 22:01

Vert.x is one of the fastest growing elements in the Spring ecosystem, and securing a Vert.x server can be a challenge. Deploying Okta allows you to add secure single sign-on to your server and while granting you access to a wealth of information about your users. This tutorial will walk you through standing up a new Vert.x server and integrating it with Okta for secure user management.

A Quick Recap of the 3-Legged OAuth Flow

This example will be using the third-party provider OAuth flow known as the 3-legged flow (the meat of single sign-on). Before launching into the code, a brief refresher of this process might be helpful.

Categories: Java

Running on Time With Spring’s Scheduled Tasks

Javalobby Syndicated Feed - Tue, 06-Feb-18 14:01

Do you need to run a process every day at the exact same time like an alarm? Then Spring’s scheduled tasks are for you. Allowing you to annotate a method with @Scheduled causes it to run at the specific time or interval that is denoted inside it. In this post, we will look at setting up a project that can use scheduled tasks as well as how to use the different methods for defining when they execute.

I will be using Spring Boot for this post, making the dependencies nice and simple due to scheduling being available to the spring-boot-starter dependency that will be included in pretty much every Spring Boot project in some way. This allows you to use any of the other starter dependencies, as they will pull in spring-boot-starter and all its relationships. If you want to include the exact dependency itself, use spring-context.

Categories: Java

WireMock With Dynamic Proxies

Javalobby Syndicated Feed - Tue, 06-Feb-18 10:01

In this series, let's learn about the WireMock dynamic proxy. We will also see how to switch mocks real service requests. For more information on learning WireMock, visit this link.

In this example, I used the OpenWeather API to get weather information. Click here for more details.

Categories: Java

Test-Driving Kotlin in ZK

Javalobby Syndicated Feed - Tue, 06-Feb-18 07:01

Every now and then it's time to learn something new — especially for a software developer. Be it just to keep in touch with recent developments, to challenge yourself by getting out of your comfort zone, or to widen your perspective and get fresh ideas on something you already know.

Very often, this means trying out the latest framework or a new platform. Sometimes, you work on an existing project and several decisions are already set in stone.

Categories: Java

Gradle and Its New Kotlin DSL [Video]

Javalobby Syndicated Feed - Tue, 06-Feb-18 04:01

A couple of months ago, the Gradle team decided that you can now also write your build.gradle files with Kotlin instead of Groovy. Although this whole effort is still in its infancy, it can turn out to be quite exciting. Why? 

Because with  Kotlin build.gradle.kts files, you get compile errors if you specify incorrect options. You get autocompletion. Basically, everything a statically typed language offers you. That does not mean that your Groovy scripts will be deprecated in the future — they will still be supported. Rather, it means you now have the choice to choose whatever suits you best and you think makes you more productive.

Categories: Java

Java Phasers Made Simple

Javalobby Syndicated Feed - Tue, 06-Feb-18 01:01

I recently came across Java phasers while reviewing different constructs for inter-thread communication. Phasers are associated to the concepts of fuzzy barriers and point-to-point synchronization.

As for this post, I will borrow the example of the one-dimensional stencil to explain very intuitively the motivation behind the concept of phasers.

Categories: Java

Deep Learning Workshop at codecentric AG in Solingen

codecentric Blog - Mon, 05-Feb-18 23:06

Big Data – a buzz word you can find everywhere these days, from nerdy blogs to scientific research papers and even in the news. But how does Big Data Analysis work, exactly? In order to find that out, I attended the workshop on “Deep Learning with Keras and TensorFlow”.

On a stormy Thursday afternoon, we arrived at the modern and light-flooded codecentric AG headquarters. There, we met performance expert Dieter Dirkes and Data Scientist Dr. Shirin Glander. In the following two days, Shirin gave us a hands-on introduction into the secrets of Deep Learning and helped us to program our first Neural Net. After a short round of introduction of the participants, it became clear that many different areas and domains are interested in Deep Learning: geologists want to classify (satellite) images, energy providers want to analyse time-series, insurers want to predict numbers and I – a humanities major – want to classify text. And codecentric employees were also interested in getting to know the possibilities of Deep Learning, so that a third of the participants were employees from the company itself.

The second day began with a tasty Latte Macchiato and a nice “Good Morning” in the big kitchen of codecentric headquarters. The friendly room, with real moss on the only wall that’s not glass, emanated a very creative air and made the start of the day much easier. For this day, Shirin had a Neuronal Net prepared, that we could use to apply and try out what we’ve learned. We spent a lot of time exploring the effects that changing different parameters had on the performance of the Neural Net. During the practical part, many questions came up, that Shirin answered and discussed with us. We also talked about our own projects and ways to advance them with what we learned in the workshop.

Deep Learning with Artificial Neural Nets

Artificial Neural Nets (ANN) can be used to analyse highly complex data. Deep Learning is a subdomain of machine learning, which is again a subdomain of Artificial Intelligence. ANNs are modelled after the human brain, which has been adapted to learn efficiently and transfer knowledge to new scenarios. Researchers tried to mimic the brains ability to learn by building ANN, which are able to learn from training data and transfer this knowledge to new data.

Gehirn vs Artificial Neural Network

Already back in 1958, Frank Rosenblatt [1] presented his concept of ANNs, the so called perceptron. The perceptron works with a numeric input and uses weighted connections in a node or neuron; together with an activation function, it calculates the result.

With increasing computational power and increasing amounts of data, multi-layer perceptrons and deep neural nets became more and more prevalent. Alongside the boom in machine learning, more and more deep learning frameworks, libraries and programming interfaces were developed. Today, there is a plethora of easy-to-use and open-source materials for deep learning. The bar to get your feet wet with this complex topic is as low as never before; you need almost no deep mathematical knowledge any more in order to build neural nets.

TensorFlow and Keras

TensorFlow and Keras are such deep learning APIs. TensorFlow has been developed by Google Brain and has been written in Python and C++. Right now, it is one of the most often used open-source libraries for machine learning. Keras builds on top of it and works specifically with neural nets. Same as TensorFlow, it is open-source and has been written in Python. There are several other libraries that can be used as backend with Keras, e.g. Theano and CNTK. TensorFlow is based on the concept of data flow graphs, meaning that every neural net can be seen as a form of mathematical operation in nodes and multi-dimensional data objects, the so called tensors, as edges. With TensorFlow we can use the integrated TensorBoard. TensorBoard is a collection of visualisation tools, that makes it easy to analyse processes, potential errors and optimize neural nets.

TensorBoard Beispiel

Image classification with Neural Nets

Most of the research into neural nets has so far involved image classification. The most famous data set for this task is MNIST [2], which contains 28 x 28 pixel images of hand-written images and their respective labels. The MNIST dataset is optimal for getting started with image classification and neural nets. Classification with neural nets falls into the category of supervised learning because it uses examples to train models. The hand-written digits of the MNIST dataset can be used to learn a classification task, namely which pixel arrangement corresponds to which digit.

MNIST Dataset

The neural net will be fed input data from the training set, which it will pass on to the next layer of neurons. The initial weights were picked at random and every neuron in a layer will calculate an output based on the incoming data and the weights. The output will then be passed on again to following layers. In the final layer, a softmax function calculated the probabilities, with which it sorts the input image to the classes. The prediction of this input will be the class with the highest probability. Because we know the correct class for every image in our training set, we can calculate the difference between prediction and correct class. This is called cross-entropy. A cross-entropy of 0 would mean that the neural net predicted the correct class with 100% certainty. After every cycle of training, we calculate an error rate, the so called loss, which represents the cross-entropy of the entire training set.

During training, we aim to minimize the loss function. In order to achieve this, the weights of the neurons need to be optimized, e.g. by using backpropagation with stochastic gradient descent. The direction in which to change the weights is found with a gradient; we want to “descend” this gradient to find the smallest error rate. The step size with which we traverse the gradient landscape is defined by the learning rate. We can start with big steps to prevent getting stuck in local minima, but with advanced training we want to reduce the learning rate so that we can – ideally – reach the global minimum. With a loss function of 0, we would have achieved the perfect result.

The final evaluation of our neural net’s performance is measured on independent test data. We want to avoid that our net learned the training set too specifically and isn’t able to generalize any more. There are many different parameters that can be adjusted when training a neural net to find the optimal composition for our classification tasks. We try out different combinations and observe the effect they have on the result.

I want to thank Shirin for a great workshop! You made the complex topic of deep learning and neural nets much more accessible to us.

Maria Hartmann

Workshop description: https://www.codecentric.de/schulung/deep-learning-mit-keras-und-tensorflow/

[1] Rosenblatt, Frank (1985). The Perceptron: A Probabilistic Model for Information Storage and Organization in the Brain. Web: http://citeseerx.ist.psu.edu/viewdoc/download?doi=

[2] LeCun, Yann. The MNIST Database of Handwritten Digits. Web: http://yann.lecun.com/-exdb/mnist/

Guest author Maria Hartmann studies Digital Humanities at the University of Trier. Through her love of linguistics she came to the classification of semi-structures texts with neural nets – which she now works on for her Master’s thesis. TensorFlow and Keras help her in her studies.


The post Deep Learning Workshop at codecentric AG in Solingen appeared first on codecentric AG Blog.

Categories: Agile, Java, TDD & BDD

An Early Look at Features Targeted for Java 11

Javalobby Syndicated Feed - Mon, 05-Feb-18 22:01

With JDK 10 about to enter its release candidate phase, it's interesting to start looking at what will come after that via JDK 11. As of this writing, four JEPs (JDK Enhancement Proposals) have been officially targeted for JDK 11 (with more likely to come). This post summarizes some details about each of the four JEPs currently targeted for JDK 11.

JEP 309: Dynamic Class-File Constants

JEP 309 ("Dynamic Class-File Constants") "seek[s] to reduce the cost and disruption of creating new forms of materializable class-file constants, which in turn offers language designers and compiler implementors broader options for expressivity and performance." JDK bug JDK-8189199 ("Minimal ConstantDynamic support") "implement[s] JEP 309 by properly parsing and resolving new CONSTANT_Dynamic constants in JVM class files used by Hotspot" and was resolved four days ago. JEP 309 was officially targeted for JDK 11 on 14 December 2017.

Categories: Java

Software Design Principles

Javalobby Syndicated Feed - Mon, 05-Feb-18 14:01

Software design has always been the most important phase in the development cycle. The more time you put into designing a resilient and flexible architecture, the more time will save in the future when changes arise.

Requirements always change — software will become legacy if no features are added or maintained on regular basis — and the cost of these changes are determined based on the structure and architecture of the system. In this article, we'll discuss the key design principles that help in creating easily maintainable and extendable software.

Categories: Java

JDK 10 Release Candidate Phase

Javalobby Syndicated Feed - Mon, 05-Feb-18 10:01

Mark Reinhold's mailing list message "JDK 10 Release Candidate Phase: Process proposal" was posted today and opens with the sentence, "Per the JDK 10 schedule, we'll enter the Release Candidate Phase next week, on Thursday, 8 February." Reinhold proposes that the JDK 10 Release Candidate Phase be enacted in the same manner as the JDK 9 Release Candidate Phase and he provides a link to the (proposed) "JDK 10 Release-Candidate Phase" page. That page outlines the proposed processes associated with the JDK 10 Release Candidate Phase with a specific focus on the level of bug fixes targeted for JDK 10. The bugs are categorized as P1 through P5 and once the JDK 10 Release Candidate Phase is entered, "all P2-P5 bugs must be left to future releases" and the focus will be on fixing "all P1 bugs that are new in JDK 10 and critical to the success of the release."

At the time of this writing, the following twelve features are targeted for JDK 10 as we're about to enter the Release Candidate Phase:

Categories: Java

Morning Java: Fresh Starts

Javalobby Syndicated Feed - Mon, 05-Feb-18 07:01

Welcome back to another round of Morning Java! The year is still relatively fresh, so let's dive into what's been going on in the Java world. This month, check out how to get things done in Java 9, how to better your career this year, and what's going on as Java EE transitions to EE4J. 

It's Java'clock

By the way, if you're interested in writing for your fellow DZoners, feel free to check out our Writers' Zone, where you can also find some current hot topics and our Bounty Board, which has writing prompts coupled with prizes.

Categories: Java

20 Books Java Programmers Should Read in 2018

Javalobby Syndicated Feed - Mon, 05-Feb-18 04:01

Welcome to 2018, guys. If you are thinking of learning new things or want to improve your knowledge of essential Java technologies, then reading books can definitely help you. Today, I am going to share some of the best Java books from the last a couple of years that you can read in 2018 to learn Java and related technology better.

The list includes books to learn Java 8, Java 9, Spring 5, Groovy, Scala, Hibernate, Spring, Agile, Scrum, microservices, algorithms, and other important stuff for Java developers. You don't need to read all of the books — this list will give you some ideas about interesting books on the things you want to learn — but if you are a nerd like me and have some time to read books, particularly during a commute, then this is quite an interesting list to follow. 

Categories: Java

A Reactive Emoji Tracker With WebClient and Reactor: Consuming SEE

Javalobby Syndicated Feed - Mon, 05-Feb-18 01:01

In this article, we will learn how to consume an infinite SSE (server-sent events) stream with Spring's WebClient and Project Reactor. WebClient is a new HTTP client in Spring 5, entirely asynchronous and natively supporting the Flux and Mono types. You can technically open thousands of concurrent HTTP connections with just a handful of threads. In standard RestTemplate, one HTTP connection always needs at least one thread.

As an example, let's connect to this cute little site called emojitracker.com. It shows emojis being used in real time on Twitter. Looks quite cool! All credit goes to Matthew Rothenberg, the creator of that site. It's very dynamic, so there obviously has to be some push mechanism underneath. I wore my hacker glasses, and after hours of penetration testing, I discovered the following URL in Chrome DevTools: http://emojitrack-gostreamer.herokuapp.com/subscribe/eps. If you connect to it, you'll get a fast stream of emoji counters:

Categories: Java

Spring Cache Annotation Tips and Tricks

Javalobby Syndicated Feed - Sun, 04-Feb-18 22:01

For Spring users, here is a list of tips to keep in mind when implementing caching annotations.

Beware of the Default Cache Keys

Caching a method outcome is really easy to do. Simply adding @Cacheable with a cache name would work already:

Categories: Java

Creating Annotations in Java

Javalobby Syndicated Feed - Sat, 03-Feb-18 23:01

Annotations are a powerful part of Java, but most times we tend to be the users rather than the creators of annotations. For example, it is not difficult to find Java source code that includes the @Override annotation processed by the Java compiler, the @Autowired annotation used by the Spring framework, or the @Entity annotation used by the Hibernate framework; but rarely do we see custom annotations. While custom annotations are an often-overlooked aspect of the Java language, they can be a very useful asset in developing readable code and just as importantly, useful in understanding how many common frameworks, such as Spring or Hibernate, succinctly accomplish their goals.

In this article, we will cover the basics of annotations, including what annotations are, how they are useful in large-than-academic examples, and how to process them. In order to demonstrate how annotations work in practice, we will create a Javascript Object Notation (JSON) serializer that processes annotated objects and produces a JSON string representing each object. Along the way, we will cover many of the common stumbling blocks of annotations, including the quirks of the Java reflection framework and visibility concerns for annotation consumers. The interested reader can find the source code for the completed JSON serializer on GitHub.

Categories: Java

CDI (Part 2): Qualifiers in Java: Polymorphism in DI

Javalobby Syndicated Feed - Fri, 02-Feb-18 23:01


This is the Part 2 of the CDI Series in Java that contains:

Categories: Java

Java 9 Modules (Part 2): IntelliJ and Maven

Javalobby Syndicated Feed - Fri, 02-Feb-18 14:01

In this post, we will take a closer look at Java 9 modules. The focus lies on how modules affect us when using an IDE like IntelliJ and using a build tool like Maven. It is advised to read the post Java 9 Modules (Part 1): Introduction. We will use the same example, starting with a single module application and, afterward, converting it into a multi-module application. The examples used can be found on GitHub.

Maven Modules, Java Modules, and IntelliJ Modules

Before we start, it is a good idea to take a look at the difference between Maven modules, Java modules, and IntelliJ modules.

Categories: Java

Advanced Akka: Multi-Data Center Clustering and Persistence [Presentation]

Javalobby Syndicated Feed - Fri, 02-Feb-18 10:01

By now, you’ve probably heard of Akka, the JVM toolkit of choice for companies like Verizon, Intel, PayPal, Norwegian Cruise Lines and Samsung when it comes to building scalable, resilient and resource efficient applications in Java or Scala. With over 12 open-source and commercial modules in the toolkit, Akka takes developers from actors on a single JVM, all the way out to network partition healing and clusters of servers distributed across fleets of JVMs. 

In this technical webinar, O’Reilly author and Lightbend Developer Advocate Hugh McKee takes you on a deep dive into advanced Akka features for enhanced application resilience, elasticity, and responsiveness.

Categories: Java

Thread Slivers eBook at Amazon

Syndicate content