From Sensors to Decisions: How Multimodal AI Agents Are Transforming Public Safety
Drone and IoT Security: The Next Cyber Battlefield
How AI-Driven Configuration Simplifies Customer Onboarding
How AI is reducing false alarms in security monitoring
7 Ethical Considerations for AI-Driven Public Safety Solutions
Integrating SendGrid Seamlessly with Java Applications
Apache Kafka: Next-Generation Distributed Messaging System
Java 17 New Features and How to Upgrade from Java 8 to Java 17
Introduction
In this blog, we will discuss the features of Java 17 and how to upgrade an existing backend application operating on Java 8 to Java 17. From Java 8 to Java 17, there have been several improvements to the Java environment and the Java environment has changed tremendously from Java 8. The most notable change is the Java release cycle. Java 8 was published in 2014, and Java 17 was issued as the following Long-Term Support (LTS) release on September 21, 2021. The next LTS release will be Java 21 in 2023. There is a seven-year gap between the two releases. However, because Java is being updated every six months, you should expect a new version every six months. This is a big change for the Java ecosystem since it allows developers to have immediate access to the latest Java features.
Java 17 New Features
- Flexible main method
- Records
- Switch Expressions
- Text blocks
- Pattern matching for instanceof
- Sealed Classes
1. Flexible Main Method
Java now supports numerous entry points to an application in contrast to the conventional “public static void main (String [] args),” allowing for greater flexibility and expressiveness in the creation and execution of programs.



2. Records
Records is a new feature that was introduced in Java 14. You can make classes that are utilized to store data. Records are identical to POJO classes but need far less code because they don’t need any external libraries, unlike most developers who use Lombok to create POJO classes. In the sample below, you can see how little code is required to construct a record class.






3. Switch Expression
In Java 17, you can return the full switch expression rather than utilizing the break keyword to exit the switch statement or the return keyword on each switch case to return a value. Instead, you can return the entire switch expression. This enhanced switch expression makes the overall code look much cleaner and easier to read.






4. Text Blocks
Text blocks are a new feature that was added to Java 15. You can make multiline strings with it without the use of escape sequences. When constructing SQL queries or JSON strings, this is incredibly helpful. You can notice how much cleaner the code looks when utilizing text blocks in the example below.






5. Pattern Matching for Instanceof
Pattern matching for instanceof is a new feature that was added to Java 16. You can use the instanceof operator as an expression to get the returned object from a casted object. When working with nested if-else statements, this is really helpful. You can see how the instanceof operator is used to catch the user object in the example below, instead of an explicit cast.






6. Sealed Classes
Sealed classes are a new feature that was added to Java 17. It allows you to restrict the number of subclasses that a class or interface can inherit from. This is really beneficial when you wish to restrict the subclasses that can be inherited from a class or interface. The example below demonstrates how the sealed keyword is used to limit the number of subclasses that can inherit a class.



How to upgrade from Java 8 to Java 17?
- Upgrade the Maven compiler plugin version
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>17</source>
<target>17</target>
</configuration>
</plugin> You can use the mvn versions:display-dependency-updates command to check for dependency updates, and the output will look like this.
- Change the JDK version for an Eclipse project
-> Open preferences in windows
- Change the JDK compliance level to 17 as shown below



2. Add JRE definition for the build path of the project as shown below









- Set Java environment path in Ubuntu
Run the below commands, get the location of JDK, and create the JAVA_HOME variable inside bashrc file as shown below.



JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64
Export JAVA_HOME
save the file and run the below command to refresh the current shell environment by running the bashrc file
source ~/.bashrc
Conclusion
In this blog, we’ve explored the exciting features of Java 17 and demonstrated how to smoothly upgrade your existing Java 8 backend application to the latest version. With enhancements like flexible entry points, records, switch expressions, text blocks, pattern matching, and sealed classes, Java 17 brings new levels of productivity and readability to your codebase. As Java’s release cycle continues to evolve, staying up-to-date with the latest features becomes more accessible, empowering developers to create efficient, modern applications.
Integration of Twilio with Java Application
Can Kafka be used for Video Streaming?
Kafka was developed around 2010 at LinkedIn by a team that included Jay Kreps, Jun Rao, and Neha Narkhede. Apache Kafka is a distributed publish-subscribe messaging system in which multiple producers send data to the Kafka cluster and which in turn serves them to consumers. In the publish-subscribe model, message producers are called publishers, and one who consumes messages is called as subscribers. Kafka has a robust queue that handles a high volume of data and passes data from one point to another. Kafka prevents data loss by persisting messages on disk and replicating data in the cluster.
Kafka Architecture:
Topic: A stream of messages of a particular type is called a topic.
Producer: A Producer is a source of data for the Kafka cluster. It will publish messages to one or more Kafka topics.
Consumer: A Consumer consumes records from the Kafka cluster. Multiple consumers consume or read messages from topics parallelly.



Brokers: Kafka cluster may contain multiple brokers. A broker acts as a bridge between producers and consumers. A Kafka cluster may contain 10, 100, or 1,000 brokers if needed. Each Kafka broker has a unique identifier number.
Record: Messages Sent to the Kafka are in the form of records. It is a key-value pair.
ZooKeeper: It is used to track the status of Kafka cluster nodes. It also maintains information about Kafka topics, partitions, etc.
Kafka Cluster: A Kafka cluster is a system that comprises different brokers, topics, and their respective partitions. Data is written to the topic within the cluster and read by the cluster itself.
Who uses Kafka ?
A lot of companies adopted Kafka over the last few years. I will list some of the companies that use Kafka.
1) Netflix
Netflix uses Kafka clusters together with Apache Flink for distributed video streaming processing.
2) Pinterest
Pinterest uses Kafka to handle critical events like impressions, clicks, close-ups, and repins. According to Kafka summit 2018, Pinterest has more than 2,000 brokers running on Amazon Web Services, which transports about 800 billion messages and more than 1.2 petabytes per day, and handles more than 15 million messages per second during the peak hours.
3) Uber
Uber requires a lot of real-time processing. Uber collects event data from the rider and driver apps. Then they provide this data for processing to downstream consumers via Kafka.
4) LinkedIn
Apache Kafka originates at LinkedIn. Linked uses Kafka for monitoring, tracking, and user activity tracking, newsfeed, and stream data.
5) Swiftkey
Swiftkey uses Kafka for analytics event processing.
Apart from the above-listed companies, many companies like Adidas, Line, The New York Times, Agoda, Airbnb, Oracle, Paypal, etc use Kafka.
Why can Apache Kafka be used for video streaming?
- High throughput – Kafka handles large volume and high-velocity data with very little hardware. It also supports message throughput of thousands of messages per second.
- Low Latency – Kafka handles messages with very low latency in the range of milliseconds.
- Scalability – As Kafka is a distributed messaging system that scales up easily without any downtime. Kafka handles terabytes of data without any overhead. It can scale up to handling trillions of messages per day.
- Durability – As Kafka persists messages on disks this makes Kafka a highly durable messaging system. Also one of another reason for durability is message replication due to which messages are never lost.
Other reasons to consider Kafka for video streaming are reliability, fault tolerance, high concurrency, batch handling, real-time handling, etc.
Neova has expertise in message broker services and can help build micro-services based distributed applications that can leverage the power of a system like Kafka.
References :
- https://kafka.apache.org/powered-by
- https://kafka.apache.org/documentation/
- https://blog.softwaremill.com/who-and-why-uses-apache-kafka-10fd8c781f4d























