Feed aggregator

Java Command-Line Interfaces (Part 23): Rop

Javalobby Syndicated Feed - 3 hours 59 min ago

The Rop library is described on its main page as "a lightweight command line option parser written in Java." The "Introduction" to Rop also states, "Rop is designed to be minimal meanwhile convenient, and to cover most usual command line parsing use cases." This post is the twenty-third in this series on parsing command line arguments in Java and focuses on Rop.

Like the 22 posts in this series before this one, this post uses examples implementing two command line options, one for file path and name and one for verbosity level. The full code listing the example is available on GitHub.

Categories: Java

Reactive Data Platforms, Real-Time Analytics, and Scale

Javalobby Syndicated Feed - 7 hours 59 min ago

Thanks to Alex Silva, Principal Data Architect at Pluralsight, for sharing his insights on the current and future state of the company’s data platform. Alex will be speaking during the Reactive Summit in Austin, Texas on Thursday, October 19, on “Designing A Reactive Real-Time Data Platform: Architecture and Infrastructure Challenges.” Click here to register for the summit.

Q: How is your company using a data platform to provide solutions to clients?

Categories: Java

15 Productivity Tips for Eclipse Java IDE Users

Javalobby Syndicated Feed - 13 hours 59 min ago

With over 10 years of releases and countless extensions and plugins, Eclipse remains one of the most popular IDEs for developers working across several domains. Especially those in the Java ecosystem, where Eclipse provides a solid environment for developing, debugging and running applications. In this post, I'd like to share my favorite features in Eclipse that help me be more productive in my daily work as a Java developer. These features don't require any plugin to be installed if the very first tip is followed.

1. Use Eclipse Oxygen

There are many improvements in the last release of Eclipse alone, and with the latest build released just a few days ago, the IDE supports Java 9 out of the box. Some of these improvements are:

Categories: Java

Modernizing Java Apps for IT Pros [Videos]

Javalobby Syndicated Feed - 16 hours 59 min ago

Today, we start releasing a new video series in Docker’s Modernize Traditional Apps (MTA) program. These are the first 4 of a 5 part video series in Docker’s Modernize Traditional Apps (MTA) program, aimed at Java IT Pros. The video series shows you how to move a Java EE app on JBoss Wildfly to a Docker container and deploy it to a scalable, highly-available environment in the cloud – without any changes to the app.

Part 1 introduces the series, explaining what is meant by “traditional” apps and the problems they present. Traditional apps are built to run on a server, rather than on a modern application platform. They have common traits, like being complex to manage and difficult to deploy. A portfolio of traditional applications tends to under-utilize its infrastructure and over-utilize the humans who manage it. Docker Enterprise Edition (EE) fixes that, giving you a consistent way to package, release and manage all your apps without having to re-write them.

Categories: Java

blockcentric #1: Consensus mechanisms of the blockchain

codecentric Blog - 18 hours 41 sec ago

Welcome to the first article of the blockcentric column. We created it for blogging about Blockchain and all related topics. It will contain exciting articles about technology, projects, organisation and business concerns. They will contain knowledge and findings from our 20% time work but also news from the area.

Blockcentric Logo

We are looking forward to your feedback on the column and exciting discussions about your use cases.

A blockchain creates trust, traceability, and immutability through a peer-to-peer network. All transactions in the network, such as payments or event tracking in a supply chain, are confirmed by participants in the network. Thus, no central authority alone controls the validity of these events. These acknowledgments given by the participants lead to a consensus in the network, with which the data on the blockchain is continually persisted. So the majority of the participants decide whether a transaction is valid, instead of a single player. To create and implement a consensus, there are several mechanisms that I would like to explain and discuss in the following.

What are consensus mechanisms?

Each Blockchain needs to choose one mechanism that handles the agreement of all participants onto a truth about their data. It could be imagined as a consistent way to get all politicians of a parliament to agree on one opinion. As politicians probably need to discuss about this, all participants of a blockchain network do this by communicating with each other over the network. The communication protocols are thereby implemented in the software that is executed on all involved devices. What is communicated here, however, is not a political opinion but the data base of the blockchain, such as the transaction history of a currency like Bitcoin.

Currently there are mainly two of those consensus mechanisms which are well-known while other ones are still not that popular.

Proof of Work – Classical mining

We already know the term “mining” from Bitcoin, the mother of most of today’s cryptocurrencies and popular Blockchain applications. Also for the Ethereum network, transaction have to be packaged into blocks in order to be confirmed as part of the history. The correct name of it is Proof of Work (PoW). In a simple way it describes the conditions that participants of the network must prove honestly how much work they have spent in order to be able to verify transactions. Therefor they get rewarded for every block that they validate and confirm. This reward is meant as a replacement for the spent electric energy and the usage of special hardware (ASIC miner or GPU). The surplus on the rewarding amounts is profit for the miners and represents an incentive. In total, the reward for a block consists of the regular block reward and the sum of all fees from all transactions contained in the block.

Proof of Work is yet, especially for cryptocurrencies, the most used mechanism of them all. This is probably the case because it has already proven its robustness and safety since 2009. In addition, the high financial involvement of miners ensures that the generated coins are actually backed of by real value in terms of fiat money. So to speak, mining is the transition of fiat money into coins of a cryptocurrency.

As robust and proven as the procedure may be, it is also strongly criticized. The big disadvantage of Proof of Work is that a lot of electrical energy and the need for specialized hardware pollutes the environment. Lots of cryptocurrency fans and critics would like to see that consensus does not have to need for this high stress to our environment. After all more than 3% of Germanys energy consumption could be provided by savings on mining energy of the entire Bitcoin network.
Another disadvantage of this mechanism is the commonly seen split of the community in these projects. Two individual groups of interest are the result. On the one hand there are the users that need to pay transaction fees in order to get their transactions confirmed. On the other hand the miners are needed to confirm them and keep the network up. Thereby they have a primary focus on profit and try to represent their own financial goals during involved discussions and politics. Proposals on how the project and its source code implementation could be improved often lead to discussions that are clearly split into two camps, each of which represent their own interests.

Proof of Stake – Shareholders with a voice

Like in a joint-stock company, shareholders have a right on participating on the consensus in the mechanism called Proof of Stake (PoS). This claim to the right of validation of a block of new transactions is given deterministically (by pseudo-randomness) over and over again.
Thereby shareholders with more wealth in their wallet have a slightly higher chance of being selected. On the one hand they have a high interest in the stable functionality of the network and should also participate in keeping it up. On the other hand there is a danger of centralising the confirmation of blocks too much as wealthy shareholders can get even richer over time.
In most cases all tokens/coins in Proof of Stake based blockchains were pre-mined (already created before usage has started) in contract to PoW, where coins are slowly flushed into the market until the maximum supply is reached. So, PoS blockchains circulating supply of tokens is already exhausted. Therefore shareholders who were chosen for validating a block can only be rewarded by transaction fees.

The process is now used successfully in some blockchains and projects, also in the world of cryptocurrencies, and finds more and more appeal. Last but not least this is also a result of the fact that electric energy is not wasted anymore. The energy consumption is limited to the usage and validation activities of users and is not artificially increased by unnecessary complex calculations.
Furthermore the community is not split automatically into two camps but is united by being more or less serious users of the individual blockchain application. Nevertheless the risk of unfair distribution of wealth is remains. This can take place if wealthy participants are preferred on choosing the next block winner in a too high degree. Their wealth will be increased disproportionately in comparison to others. To prevent this from happening, it is important to strive for a fairest possible Proof of Stake algorithm. There are already certain variants with individual advantages and disadvantages in discussion, on which I am not going to elaborate further in this article.

Proof of Work vs. Proof of Stake – or something different?

The two best known consensus mechanisms should be known by now. We quickly realize that Proof of Stake focuses on eliminating the disadvantages of Proof of Work. The sustainability of blockchains is therefore to be increased by the significant saving of electrical energy and hardware and at the same time making the community easier to develop projects by avoiding conflicts of interest.
Nevertheless, Proof of Stake also raises questions: Can it be ensured that the rich are not getting richer? When is the block reward selection mechanism perfect and maximally fairly designed?

It does not hurt to look at other variants that want to improve on the two ideas.

Proof of Activity – A hybrid approach

This approach did not originate from the optimization of a single consensus mechanism but is a combination of PoW and PoS. It is foreseen that miners continue to solve cryptographic puzzles using a lot of electric energy and special hardware. However, the blocks found therewith are only meant to contain the identity of the block winner and its reward transaction. Then the Proof of Stake phase begins and the validators (shareholders selected to validate transactions and blocks) confirm the correctness of the block. If the block was checked often enough, the validators will finally activate it to a completed block. This step just finally ensures that open transactions are processes and are integrated into the found block containers.
Also the block reward is being split, so the validators also receive shares of it.

Proof of Importance – VIP first

The concept presented by NEM is coupled to Proof of Stake and also includes the roles of shareholders and validators. However, these are selected using a certain algorithm, not only by chance and size of their shares. Also their importance for the network and the importance that the network apparently has for them flows into the formula. In NEM’s definition of Proof of Importance (PoI) this is implemented with the inclusion of the network usage (transactions made with other participants). Participants who often send and receive transactions will find blocks more frequently. A detection of fraudulent usage and manipulative patterns is of course included into this concept to prevent spammy participants to gain a higher importance score.

In addition, only a special kind of stake is considered for the mechanism to be considered as wealth. Coins in the NEM wallet are not considered as wealth until they are vested. For every 24 hours 10% of the un-vested coins will be charged to this vested wallet. As a result, participants receive an incentive to make only necessary transactions and can only increase the importance score slowly by proving their involvement in the network.

Proof of Elapsed Time – Eco-friendly mining through innovation

This mechanism was invented by the chip manufacturer Intel and refers to the technological achievement SGX (SafeGuard Extensions). SGX includes a set of CPU instructions, which allow processes to use private resources of the CPU for their own. This is to create Trusted Execution Environments (TEE) in the CPU calculation, for which there is no danger of being manipulated from outside processes.

What does this have to do with the confirmation of transactions? The goal is to implement a real random mechanism through this innovation at low hardware and software level. In comparison to Proof of Work, it should not be determined by chance, which participants can solve their riddles using their resources. Proof of Elapsed Time (PoET) wants to replace the cryptographic puzzles involved in PoW by the fact that the CPU architecture, in combination with the quantity of the mining hardware alone, knows how often and when a participant will win a block. It should ensure a random and fair competition in finding the next block.

This approach is about reducing energy consumption during mining. Unfortunately, this adds the dependency of a supported CPU architecture to the mining hardware. The hardware could be designed much smaller and combined with regular private computers but only if they fulfill the CPU requirements.
It is also questionable whether a distributed blockchain network should trust a general purpose chip maker. Without reproaching chip manufacturers, the consensus of the Proof of Elapsed Time network would be dependent on how secure and unmanipulated the SGX is implemented and this feels strange. The consensus of the decentralized network is thus placed faithfully in the hands of a central authority.


In this article, we have looked at the concept of five possible consensus mechanisms that can be used in designing a blockchain. It is to be assumed that the success of these systems is, among other things, related to the quality and fairness of their consensus process. Also the first frameworks behind blockchain software are ready to handle consensus as a plugin-and-play concept that can be configured so that implementation will not longer be a bottleneck. Therefore, we should continue to try to find better ways to secure and even scale up blockchains (more transactions per time unit).

Selection of the needed consensus process should be made dependent on the project requirements. One should think about how disastrous the disadvantages and how useful the advantages of the individual concepts could be for the desired result of the project. It is a matter of interest groups which mechanism fits best.
Ultimately, it is not yet possible to find a universally perfect consensus mechanism that is able to eradicate all advantages of its competitors.

The post blockcentric #1: Consensus mechanisms of the blockchain appeared first on codecentric AG Blog.

Categories: Agile, Java, TDD & BDD

Migrating a Spring Boot App to Java 9: Compatibility

Javalobby Syndicated Feed - 19 hours 59 min ago

With the coming of Java 9, there is a lot of buzz on how to migrate applications to use the module system. Unfortunately, most of the articles written focus on simple Hello world applications. Or worse, regarding Spring applications, the sample app uses legacy practices — like XML for example. This post aims to correct that by providing a step-to-step migration guide for a non-trivial modern Spring Boot application. The sample app chosen to do that is the Spring Pet clinic.

There are basically 2 steps to use Java 9: first, be compatible then use the fully-fledged module system. This post aims at the former, a future post will consider the later.

Categories: Java

Tidy Config With Owner

Javalobby Syndicated Feed - Mon, 16-Oct-17 13:01
It is a truth universally acknowledged that a single program in possession of a good configuration must be in want of a way to easily access it.
—Jane Austen?

Any non-trivial software, at some point, needs a way to allow users to configure it. By far the easiest solution is to use a text file with some convention (.ini, .yaml, .json, .xml, .you name it) and parse it at the start.

Java has had support for properties files since version 1, and it’s probably the easiest way to configure Java programs. The class Properties has the methods load and store to read and write property files. So far so good.

Categories: Java

Java: Introducing Redis Mock

Javalobby Syndicated Feed - Mon, 16-Oct-17 09:01

Many software solutions built today often depend on external processes. Examples include: databases, web services, indexing services, etc.

This introduces challenges when testing software solutions. How can you simply test a solution in isolation without having to spin up instances of external processes that solution may depend on?

Categories: Java

3 Ways to Diff Java Code in IntelliJ [Video]

Javalobby Syndicated Feed - Mon, 16-Oct-17 03:01

I was busy refactoring code in RestMud this morning because I want to try and open source the basic game engine, and then later the Web/REST API, but I want to tidy up the code a little first.

I've been working through the code:

Categories: Java

F-Bound Over a Generic Type in Scala

Javalobby Syndicated Feed - Mon, 16-Oct-17 00:01

In this article, I will be mentioning Comonads and sharing my experience with Apiumhub. If you know what they are, great, and if you don’t know, no worries, because this article’s main topic isn’t Comonads. It’s actually about Scala generics, about returning the “Current” Type in Scala.

In my odyssey to understand Comonads, the first thing I did after reading about them was to implement a series of tests that would make them a little bit clearer, and I did it using the NonEmptyList implementation of the scalaz library.

Categories: Java

Kotlin: Static Methods

Javalobby Syndicated Feed - Sun, 15-Oct-17 21:01

If you come from the Java world, you are already familiar with static methods. They prevent us from copying our methods to every class and allow us to use them without creating an object. But what if I told you that we don’t have static methods in Kotlin?

It's true. But that doesn’t mean that we can’t reap the benefits provided by static methods in Kotlin. There is a way around them. Let’s see how.

Categories: Java

Reactive Spring [Video]

Javalobby Syndicated Feed - Sat, 14-Oct-17 21:01

As you might already know, Spring 5 went GA a couple of weeks ago. To celebrate this, last week we held an incredible webinar by Josh Long on Reactive Spring. If you have followed the news about the release, you probably already know, that among other things (such as JDK 9, Java EE 8, and Kotlin support), Spring 5  can integrate with Spring Reactor to support reactive programming.

In this webinar, Josh not only introduced what reactive programming is about, but also a gave a hands-on live coding demo on how to use Reactive Spring to build message-driven, elastic, resilient and responsive services–in both Java and Kotlin. The sources of the code shown in his demo are available on GitHub.

Categories: Java

Modular Java 9 Apps With Gradle and Chainsaw

Javalobby Syndicated Feed - Fri, 13-Oct-17 21:01

For the last few months, I have observed the development and adoption of the Java 9 module system, also known as Project Jigsaw. The final result is impressive, however, I also see a lot of confusion among regular developers in how to actually use modules. The tool support does not help, either. The final days of Jigsaw development were really hot, and some important decisions were made at the last minute. No doubt the authors of many popular tools had little time to make the necessary changes and, in my opinion, on September 21, we woke up a bit unprepared for Jigsaw.

My first attempt to add a module descriptor to an existing, small application was unsuccessful. I spent four hours figuring out how to solve package splits among third-party dependencies and how to add the necessary CLI switches to my Gradle build to make everything work. I found the experimental-jigsaw Gradle plugin, but I realized, that it has its own limitations, too (e.g. I could not add a mocking library to my tests, and I was restricted to JUnit 4!). However, the experience was worth it — I realized that I can use it to make a better Jigsaw plugin for Gradle and bring modules closer to developers. So, here we go with the Gradle Chainsaw Plugin!

Categories: Java

Docx Templating With docx4j: Tips and Tricks

Javalobby Syndicated Feed - Fri, 13-Oct-17 13:01

The Problem

Say we need to create a Word document (based on a template) filled with data from a system with 'unlimited' rows and a possibly 'unlimited' number of columns.

Just like in the awesome, pro, fancy picture below.
Image title

Categories: Java

Spring Tips: Bootiful, Reactive Scala [Video]

Javalobby Syndicated Feed - Fri, 13-Oct-17 09:01

Hi, Spring fans! In this tip, we’ll look at the bootiful possibilities of integrating Spring Boot and Spring WebFlux, the reactive web runtime and framework in Spring Framework 5, with Scala and the Scala ecosystem — as well as integrating the Spring WebFlux reactive runtime with other Reactive Streams implementations, like Akka Streams.

Categories: Java

JShell in Five Minutes

Javalobby Syndicated Feed - Fri, 13-Oct-17 03:01

This post builds on my My Top Java 9 Features post by looking more in depth at these features. Here we show you how you can learn JShell in five minutes, and improve your Java 9 development experience.

Getting Started

Assuming you have downloaded and installed Java 9 then you can start the shell by typing:

Categories: Java

Java Command-Line Interfaces (Part 20): JSAP

Javalobby Syndicated Feed - Fri, 13-Oct-17 00:01

JSAP (Java Simple Argument Parser) 2.1 is the focus of this twentieth post in this series on processing command line arguments from Java. The JSAP page describes the library's reason for existence: "I found several parsers on the Internet, all of which handled switches, but none of which had the versatility I wanted in terms of return types and configuration files."

JSAP offers quite a bit of flexibility at the normal cost of some complexity. Fortunately, JSAP provides a class called SimpleJSAP that makes it easier to accomplish simple tasks with JSAP. The JSAP documentation articulates it this way, "If you want to minimize the amount of code handling the command line, JSAP offers a SimpleJSAP that does most of the work for you." The next code listing demonstrates using SimpleJSAP in a single (albeit verbose) statement to define the expected command line options.

Categories: Java

JavaOne 2017 Gave a Shake to Ecosystem

Javalobby Syndicated Feed - Thu, 12-Oct-17 21:01
“Things have changed in the Java ecosystem probably more in the past three weeks than they have in the previous 13 years.”
— James Governor, RedMonk analyst and co-founder

We must admit that JavaOne 2017 in San Francisco got wide resonance: The great number of participants were actively involved in the conference, talking about Java's role in transforming the way people work and live in the digital era. The world’s largest gathering of Java developers saw discussions about the latest runtime updates, container-based solutions, and serverless architectures that help developers to build modern, distributed applications to meet the needs of their projects.javaone 2017 java community keynoteWith over 12 million developers all over the world running Java and more than 1 billion downloads each year (following Oracle), Java remains the world’s most popular programming language. Java is also the #1 developer choice for cloud, with over 21 billion cloud-connected Java virtual machines.

“We want the next decade to be Java first, Java always.”
— Mark Cavage Vice President, Product Development at Oracle

Being a Java native cloud, Jelastic is highly involved in the activities of this ecosystem. So we’d like to highlight the results of Jelastic's presence at the JavaOne event this year.javaone 2017 bruno souza jug ruslan synytsky ceo jelastic

Categories: Java

This Week in Spring: KotlinX and Reactor, Java 9, and Beyond

Javalobby Syndicated Feed - Thu, 12-Oct-17 09:01

Hi, Spring fans! Welcome to another installment of This Week in Spring! By happy coincidence, today is also Ada Lovelace day. According to the Finding Ada site: Ada Lovelace Day (ALD) is an international celebration day of the achievements of women in science, technology, engineering, and maths (STEM). It aims to increase the profile of women in STEM and, in doing so, create new role models who will encourage more girls into STEM careers and support women already working in STEM. Happy Ada Lovelace day!

I’ve just returned from the epic ByteMyCode conference in Wroclaw, Poland, and am now in Seattle, Washington to talk to customers and to hold an open event today at Pivotal Seattle on Cloud Native Java. Later today I’m off to Toronto, Canada to visit customers and appear at the SpringOne Platform Preview show happening later this week. If you’re around, don’t hesitate to stop in and say hi!

Categories: Java

Java Quiz 2: Comparing Class Variables With Instance Variables

Javalobby Syndicated Feed - Thu, 12-Oct-17 05:01

Before we dive into this week's quiz, here is the answer to Quiz 1: Overriding Methods.

  1. By creating the object of MySub, the constructor of the superclass MySuper is called.

Categories: Java

Thread Slivers eBook at Amazon

Syndicate content