Monday, November 26, 2018

From Java 8 to Java 11

Switching from Java 8 to Java 11 is more complicated than most updates. Here are some of my notes on the process.

Modules

Java 9 introduced one of the biggest changes in the history of Java modules. Much has been said on the subject, by other people. A key point is sometimes forgotten:

You do not need to modulate your code to update to Java 11.
In most cases, the code that runs in the class path will continue to run in Java 9 and later, where the modules will be completely ignored. This is terrible for library authors, but optimal for application developers.

So, my advice is to ignore the modules as much as you can when upgrading to Java 11. Transforming your application into Java modules can be a useful thing to consider in a few years when the free software dependencies really start adopting the modules. At the moment, trying to modularize is only painful, since few dependencies are modules.
(The main reason I found to modularize your application is to be able to use jlink to reduce the size of JDK.) But, in my opinion, you do not need to fully modulate to do this - just create a single jar - with dependencies with a simple no- requires no-exports module-info.)


Parties excluded from the JDK

Some parts of the JDK were removed. These were parts of Java EE and Corba that no longer fit the JDK or could be maintained elsewhere.If you use Corba, then there is little that someone can do to help you. However, if you use the Java EE modules, the correction of the deleted code should be simple in most cases. You just have to add the appropriate Maven jars.On the Java client side, things are more complicated with the removal of Java WebStart. Consider using Getdown or Update4Jinstead.

Unsafe and friends

Sun and Oracle have come to developers for years that do not use the sun.misc.Unsafe and other leading edge JDK APIs. For a long time, Java 9 was the launch where those classes disappeared. But that never really happened.

What you can get with Java 11, however, is a warning. This warning will only be printed once, on the first access to the restricted API. It is a useful reminder that your code, or a dependency, is doing something "impertinent" and will have to be corrected at some point.

What you will also discover is that Java 11 has several new APIs designed specifically to avoid the need to use Unsafe the friends. Make a priority to investigate these new APIs if you are using an "illegal" API. For example, Base64, MethodHandles.privateLookupIn, MethodHandles.Lookup.defineClass, StackWalker and Handles Variables.

Tools and Libraries

The modules and the new biannual launch cycle conspired to cause a real impact on the use of tools and libraries that developers use. Some projects were able to accompany. Some have fought. Some failed.

When updating to Java 11, an important task is to update all its dependencies to the latest version. If there is not a posting since Java 9 was released, then this dependency may need additional attention or testing. Make sure you have updated your IDE as well.

But it's not just the dependencies of the applications that need to be updated, as well as Maven (and the Gradle too, but I do not know much about the Gradle). Most Maven plugins have changed major versions to v3.x, and upgrading Maven itself to v3.5.4 is also beneficial.

Unfortunately, the maven's main equipment is very small, so there are still some errors / problems to solve. However, if your Maven construction is sensible and simple enough, it should usually be fine. But note that updating a plug-in from a v2.x to a v3.x can involve changes to the configuration in addition to those associated with the modules. For example, the Maven Javadoc plugin has changed the name of the argLine property.

Interested in learning Java? Join now:” java training in chennai “

An important point to be observed is the way in which Maven operates with the modules. When the Maven compiler or surefire plugin finds a jar file that is modular (that is, with a module-info.class), you can place that jar in the module path instead of the class path. In this way, even if you want to run the application completely on the classpath, Maven can compile and test the code partially on the classpath and partly on the module path. At the moment, there is nothing that can be done about it.
Sometimes, your compilation will need some larger changes. For example, you will have to change the Findbugs for SpotBugs. And change the Coverage to JaCoCo.
These compilation changes may take some time - they did it for me. But the information available for a simple investigation on the web is increasing all the time.

Interested in learning Java? Join now:” java training in bangalore

Summary

I have updated several Joda / ThreeTen projects to support Java 9 or later now. It was very painful. But that's because, as the author of a library, I have to produce a jar file with module information that is built and executed in Java 8, 9, 10 and 11. (In fact, some of my jar files run in Java 6 and 7 too!)

Having made these migrations, my conclusion is that the pain is mainly in maintaining compatibility with Java 8. Moving an application to Java 11 should be simpler, because there is no need to get stuck in Java 8.




Sunday, November 25, 2018

Java 101

A complete introduction for beginners to the Java platform

So, do you want to program in Java? This is great and you have come to the right place. The Java 101 series provides a self-guided introduction to Java programming, starting with the basics and covering all the main concepts you need to know to become a productive Java developer. This series is technical, with many code examples to help you understand the concepts as we go. I guess you already have some experience in programming, but not in Java.

This inaugural article presents the Java platform and explains the difference between its three editions: Java SE, Java EE and Java ME. You will also learn about the role of the Java virtual machine (JVM) in the implementation of Java applications. I'll help you set up a Java Development Kit (JDK) on your system so you can develop and run Java programs, and start with the architecture of a typical Java application. Finally, you will learn how to compile and run a simple Java application.

What is Java?

You can think of Java as a general-purpose object-oriented language that looks a lot like C and C ++, but which is easier to use and allows you to create more robust programs. Unfortunately, this definition does not offer much information about Java. A more detailed definition of Sun Microsystems is as relevant today as it was in 2000:
Java is a simple computer language, object oriented, intelligent in network, interpreted, robust, secure, with neutral architecture, portable, high performance, multithread and dynamic.


We will consider each of these definitions separately:

Java is a simple language. Java was initially modeled after C and C ++, minus some potentially confusing resources. Pointers, multiple implementation inheritance and operator overload are some C / C ++ resources that are not part of Java. A non-mandatory feature in C / C ++, but essential for Java, is a garbage collection feature that automatically retrieves objects and arrays.

Java is an object-oriented language. The object-oriented Java approach allows developers to work on Java adaptation to solve a problem instead of forcing us to manipulate the problem to meet language restrictions. This is different from a structured language like C. For example, while Java allows you to focus on objects in the savings account, C requires that you think separately about the state of the savings account (such balance) and behaviors ( as deposit and drawing).

Java is a language with network knowledge. The extensive Java network library makes it easy to manage TCP / IP network protocols, such as HTTP (Hypertext Transfer Protocol) and FTP (File Transfer Protocol) and simplifies the task of making network connections. In addition, Java programs can access objects through a TCP / IP network, through resource locations (URLs), with the same ease with which they are accessed from the local file system.

Java is an interpreted language. At run time, a Java program runs indirectly on the underlying platform (such as Windows or Linux) through a virtual machine (which is a software representation of a hypothetical platform) and the associated execution environment. The virtual machine translates the bytecodes of the Java program (instructions and associated data) for specific instructions of the platform by means of interpretation. Interpretation is the act of discovering what a bytecode instruction means and then choosing equivalent "canned" platform-specific instructions to execute. The virtual machine then executes these platform-specific instructions.

The interpretation facilitates the debugging of defective Java programs, because there is more information at compile time available at runtime. The interpretation also makes it possible to delay the connection stage between the parts of a Java program until the execution time, which accelerates the development.

Java is a robust language. Java programs must be trusted because they are used in personal and mission-critical applications, from Blu-ray players to air navigation systems or air control. The language resources that help make Java robust include declarations, duplicate type checking at compile time and runtime (to avoid version incompatibility issues), true arrays with automatic boundary checking and pointer omission. 

Another aspect of Java's robustness is that loops must be controlled by Boolean expressions instead of integer expressions, where 0 is false and a non-zero value is true. For example, Java does not allow a loop in style C, such as while (x) x ++; because the loop cannot end where it is expected. Instead, you must explicitly provide a Boolean expression, such as while (x! = 10) x ++; (which means that the loop will run until x equals 10).

Java is a safe language. Java programs are used in network / distributed environments. Because Java programs can migrate and run across multiple platforms on a network, it is important to protect these platforms against malicious code that can spread viruses, steal credit card information, or execute other malicious acts. The characteristics of the Java language that support robustness (such as the omission of pointers) work with security features, such as the Java sandbox security model and public-key cryptography. Together, these resources prevent viruses and other dangerous codes from wreaking havoc on an unmanned platform.
In theory, Java is safe. In practice, several security vulnerabilities have been detected and explored. As a result, Sun Microsystems and Oracle now continue to release security updates.

Interested in learning Java? Join now:” java training in chennai “

Java is a neutral language in architecture. Networks connect platforms with different architectures based on various microprocessors and operating systems. You can not expect Java to generate platform specific instructions and have those instructions "understood" by all types of platforms that are part of a network. Instead, Java generates platform-independent byte code instructions that are easy to interpret for each platform (through its JVM implementation).

Java is a portable language. The neutrality of architecture contributes to portability. However, there is more to Java portability than platform-independent byte code instructions. Consider that the sizes of integer types should not vary. For example, the 32-bit integer type should always be signed and occupy 32 bits, regardless of where the 32-bit integer is processed (for example, a platform with 16-bit registers, a platform with 32-bit registers or a table platform with 64-bit registers). Java libraries also contribute to portability. When necessary, they provide types that connect Java code to platform-specific resources in the most portable manner possible.

Interested in learning Java? Join now:” java training in bangalore

Java is a high performance language. The interpretation produces a level of performance that is generally more than adequate. For high-performance application scenarios, Java uses just-in-time compilation, which analyzes interpreted bytecode instruction sequences and compiles frequently interpreted instruction sequences for platform-specific instructions. Subsequent attempts to interpret these sequences of bytecode instructions result in the execution of equivalent platform-specific instructions, resulting in increased performance.

Java is a multiprocess language. To improve the performance of programs that must perform several tasks at the same time, Java supports the concept of chained execution. For example, a program that manages a graphical user interface (GUI) while waiting for the input of a network connection uses another thread to execute the wait instead of using the standard GUI thread for the two tasks. This keeps the GUI responsive. The Java synchronization primitives allow the threads to securely communicate data with each other without corrupting the data. (See programming chained in Java, discussed elsewhere in the Java 101 series).

Java is a dynamic language. Because interconnections between program code and libraries occur dynamically at runtime, it is not necessary to explicitly link them. As a result, when a program or one of its libraries evolves (for example, for error correction or performance improvement), a developer only has to distribute the updated program or library. Although dynamic behavior produces less code to distribute when a version change occurs, this distribution policy can also lead to version conflicts. For example, a developer removes a class type from a library or renames it. When a company distributes the updated library, existing programs that depend on the type of class will fail. To greatly reduce this problem, Java supports a type of interface, which is like a contract between two parties.




Friday, November 23, 2018

Introduction to the Java Development Kit

The Java Development Kit (JDK) is one of the three main technology packages used in Java programming, together with the JVM (Java Virtual Machine) and the JRE (Java Runtime Environment). It is important to differentiate these three technologies, as well as to understand how they are connected:

• The JVM is the component of the Java platform that runs programs.
• The JRE is the part of the Java disk that creates the JVM.
• The JDK allows developers to create Java programs that can be executed and executed by JVM and JRE.

Beginning Java developers often confuse the Java Development Kit and the Java Runtime Environment. The distinction is that the JDK is a toolkit for Java-based software development, while the JRE is a suite of tools for executing Java code.
The JRE can be used as a separate component to run Java programs, but it is also part of the JDK. The JDK requires a JRE because running Java programs is part of their development.

• Technical definition: The JDK is an implementation of the Java platform specification, including the compiler and the class libraries.
• Definition of every day: JDK is a software package that downloads to create Java-based applications.


Start with the JDK

Obtaining Java configuration in your development environment is as easy as downloading a JDK and adding it to your classpath. When you download your JDK, you will need to select the Java version you want to use. Java 8 is the most commonly used version, but, so far, Java 10 is the most recent version. Java maintains compatibility with previous versions, so we will download the latest version.

Interested in learning Java? Join now:” java training in chennai “

JDK packages

In addition to choosing your version of Java, you will also have to select a Java package. The packages are Java development kits that are directed to different types of development. The available packages are Java Enterprise Edition (Java EE), Java Standard Edition (Java SE) and Java Mobile Edition (Java ME).
Beginning developers are sometimes not sure which package is right for their project. In general, each JDK version contains Java SE. If you download the Java EE or Java ME, you will get the standard edition with it. For example, the Jave EE is the standard platform with additional tools useful for the development of enterprise applications, such as Enterprise JavaBeans or support for Relational Object Mapping.

Interested in learning Java? Join now:” java training in bangalore

It is also not difficult to change to a different JDK in the future if you find that you need it. Do not worry much about choosing the correct version of Java and the JDK package when you have just started.































Thursday, November 22, 2018

Microservice Logging: Challenges and Advantages

One of the main developments in software design and delivery in recent years has been a movement of monolithic applications for microservices. One of the critical points that I have seen in several microservice applications is the registry. There are some unique challenges with the microsion log that need to be resolved. In this article, we will see how we can do the registration in a microservice as painless as in a monolith.

What is a microservice?

There are many definitions of microservices out there, but that's the one I like.
Microservices: A high-level software design that favors small and weakly connected services that maintain data autonomy and are independently implantable.
Breaking this up using microinsurance is a high level decision. It is not a standard that applies only to a part of your application, but it must be a global decision. By using microservices, we create several smaller applications with very limited functionality. For example, we can have a service whose responsibility is to act as a container to chat with an external API. 
Services must be weakly connected: there are no direct connections between services or cross-talk between services. Services must have their own data storage solution that is not shared with another service. This means absolutely no integration at the database level! Finally, there should be no dependencies between the services at the time of implementation.Setting limits between services in a microsystem cluster is a difficult problem. There are many ideas around it, but most of them revolve around domain-oriented design.


Different challenges of a monolith

Although there are many advantages in a microservice approach, there are also disadvantages. The monoliths are implemented as a single entity in one or more servers, each of which obtains the same code. This unique implantation is a curse and a blessing. Unique implementations mean that you have fewer moving parts in the creation and deployment pipeline. There are no concerns about data transport between various applications or discovering the limits for these applications. The most important advantage for this article is that the registration in the registry resides in only one location.
The log is a perfect example of a transversal concern: code that needs to cover several modules at different levels of the code base. When we divide our application into silos, the record is also divided into all services.

A single logging technology

 A much discussed benefit of microinsurance is that each service can be written using appropriate technology. A component that does a lot of mathematics may not be as efficient written in JavaScript as in Go. Microservices allow you to select a technology that best suits each component. Generally, each microservice is built by a team specialized in the technology used in that service. Reinforcing a single data logging technology is a challenge to the microservice mentality. However, this is a time when it is justified to go back in academic perfection in favor of pragmatism.

A shared logging implementation for every service

 A single registration technology provides us with a location for the records, regardless of which service originates the registration message. If we are trying to find a network problem, we do not want to have to go through several log files located all over the place to see what services have been affected. Ideally, we want to have a one-stop-shop that allows searching, classifying and designing registration information for several dozens of services. The technologies that allow this, registry aggregators, tend to have connectors for several languages. For example, Stackify Retrace has connectors for Java, .NET, PHP, Ruby and Node.js out of the box, as well as a Restful API that unlocks almost all other languages.
The errors can cover several microservices, so the registry as our best tool to track errors must also cover them.

A logging technology which allows queries

 A single user interaction in a microsystem architecture can encompass many services. Being able to accompany a user interaction is much easier if you have a registration tool that allows you to use an advanced query language to search, design and add. The registration in aggregate can also be very useful. Queries like this one are super-valuable: "what percentage of requests for X service results in errors?", Or "what time of day do we see the biggest load on the system", or even "what is the average time that an application spend? in the X service. "
Naturally, there are many registry aggregators out there, and choosing one that has an advanced query language is a good differential. Another aspect to consider is how easy it is to see the data after writing a query for them. A good chart will give you background information that are difficult to analyze from a record message.
Next, there is an example of a Retrace panel showing several important metrics, some of which are extracted from record searches.

Interested in learning Java? Join now:” java training in chennai “

Use a correlation identifier

When a client contacts you with a problem you had in your application, it is very good to be able to quickly find what has gone wrong. One method to do this in a micro security application is to include a correlation or transaction ID in each message. Fill this field with an ID removed from the initial event. Consider a scenario in which a user creates an account. This can trigger actions in the user's service, in the customer loyalty service and in the billing service.

By having a unique identifier that is disconnected by each of these services while processing a message, it is easy to find the creation flow of the user. All that is needed is to pop the unique identifier in the search engine of the record aggregator and get all the registration messages related to that transaction. You can even present the user with that correlation ID, if something goes wrong, so you have a reference number to quote when talking to your support organization; This is even more useful if you are the support organization.
Interested in learning Java? Join now:” java training in bangalore

Include a lot of information
It is much more common that you want to have more information recorded than less. Obviously, there are some performance and storage considerations in relation to over-registration, but very small registration can lose the main information forever. Including context information in your log messages increases the chances that you can track problems. For example, it usually improves my log messages with information such as:

• service name that generates the registration message
• Correlation ID
• username that triggered the action
• machine name or container id
• date of receipt of the message in UTC
• date of sending the message in UTC
• entire body of the drive message

Carefully consider what information would be useful in debugging problems and you would be wrong to include too much. If you are using a registration structure that supports structured registration (which is excellent), you can place all this information in the properties of the logging message and not overload your actual messages.




Wednesday, November 21, 2018

Java EE Overview

In this article, you will find information about the history of the Java EE ecosystem: where it came from and how it has changed in recent decades. You will discover the main milestones in its development, from J2EE 1.2 to its current incarnation Java EE 7, and we will see in the future what Java EE 8 has reserved.

You will discover how to get involved with the development of the platform itself and how to enter JCP.org to make an even greater contribution. Find out about the Java EE Guardians and how you can support the development and growth of the platform.

What is Java EE?

Java EE consists of a set of more than 28 specifications and a runtime environment. It is a superset of the Java SE platform. This means that Java EE components can take full advantage of all Java SE APIs.

This set of APIs creates multilayer applications based on standard components and implements in different containers, offering a variety of services. It is not only used to develop monolithic application structures, but also structured applications of microsystems. More information about Java EE and microservices checking Java EE and Microservices in 2016? You are interested in the development of tip in the space of microservices with respect to Java EE? Next, visit the Eclipse Microprofile project website.

The Java EE programming model has annotations to specify settings instead of XML description files and uses the configuration convention to help you start using the least possible ceremony.

It has its own contextually conscious dependency injection structure at the center of its programming model.

History of Enterprise Java

In 1998, the first incarnation of Enterprise Java was launched, but then important technologies soon joined the mix, such as Servlets, Messaging and Enterprise Java Beans.



These technologies still exist on the Enterprise platform today, but in a much more advanced and complete way.

In the following years, he developed a programming model that was difficult to use and very complicated. All this changed in the fifth edition, which saw a radical change of the XML configuration towards the notes and convention about the configuration.

The new programming model has been substantially simplified. Annotations replace the XML description files, the configuration convention replaces the tedious manual configuration, and dependency injection hides the creation and search for resources. Resources are created and injected into injection points marked by annotations such as @Inject. Therefore, all you need is a POJO that meets the conditions of the managed beans specification, JSR 299 and, depending on the annotation used, it will become an EJB, Servlet, Singleton or RESTful Web service.

The platform continued to grow, but at a much slower pace. To each new version, it becomes more friendly to the programmer and the number of APIs grew to reach 28+, above only a handful of five APIs in 1999.


Interested in learning Java? Join now:” java training in chennai “

What comes in Java EE 8?

Oracle is moving the focus of Java EE to microservices and the cloud, and the next version of Java EE will include the APIs that complement this new address.

As well as advances in some established technologies, such as Bean Validation, Context Injection and Dependency, JavaServer Faces, JAX-RS (RESTful web services), JSON-Processing and Servlets, there will be two new APIs.

JSON-binding, a dedicated security API and security API for Java EE, designed to standardize security.

The Java EE 9 will see even more APIs designed for the development of microsis and cloud-based applications.


Interested in learning Java? Join now:” java training in bangalore

Java Community Process (JCP)

The development of the Java EE platform occurs through the Java Community Process (JCP), responsible for all Java technologies.

The group of experts consists of interested parties who created Java specification requests (JSR) to define the various Java EE technologies. All done in cooperation with the international community of Java developers.

The work of the Java community under the JCP program helps to guarantee the stability and compatibility standards between Java technology platforms.

Anyone can review and comment on draft specifications and JSR proposals, as well as read the JCP blog. Anyone can register as user

Anyone can review and comment on draft specifications and JSR proposals, as well as read the JCP blog. Anyone can register as a user of the site and can be authorized as a member of the Collaborator or the Group of Experts. You can become a JCP member and make an even greater contribution. Go to the link to discover more.





From Java 8 to Java 11

Switching from Java 8 to Java 11 is more complicated than most updates. Here are some of my notes on the process. Modules Java 9 i...