Thursday, 31 July 2025

Java LTS Versions Compared: Java 8 vs 11 vs 17 vs 21

 Java has come a long way since Java 8, and with each Long-Term Support (LTS) release, the language and platform have evolved significantly. Whether you're a developer, architect, or team lead, understanding the differences between Java LTS versions can help you choose the right version for your project.

In this blog post, we'll compare the major LTS versions: Java 8, 11, 17, and 21 — highlighting their key features, improvements, and what makes each version special.


☕ Java 8 (LTS) — March 2014

Major Features:

  • ✅ Lambda Expressions (functional programming)

  • ✅ Streams API

  • ✅ Default Methods in Interfaces

  • java.time package (modern date/time API)

  • ✅ Optional<T> to reduce null checks

  • ✅ CompletableFuture for async programming

🔍 Why it matters: Java 8 was a revolution — introducing functional-style programming and new APIs that changed how Java is written.


☕ Java 11 (LTS) — September 2018

Major Features:

  • ✅ Local-variable syntax for lambdas

  • ✅ New HTTP Client (supports HTTP/2)

  • ✅ New String methods: isBlank(), lines(), repeat()

  • ✅ File I/O improvements: readString(), writeString()

  • ✅ Single-file source-code launcher: java Hello.java

  • ❌ Removed outdated modules: CORBA, Java EE

🔍 Why it matters: Java 11 brought performance gains and cleaner syntax, making it a solid upgrade target from Java 8.


☕ Java 17 (LTS) — September 2021

Major Features:

  • ✅ Sealed Classes – Control class inheritance

  • ✅ Pattern Matching for instanceof

  • ✅ Records – Concise data classes

  • ✅ Switch Expressions – More powerful and expressive

  • ✅ Text Blocks – Multiline strings with ease

  • ✅ New Random Number Generators API

🔍 Why it matters: Java 17 improves readability, reduces boilerplate, and introduces more expressive language features.


☕ Java 21 (LTS) — September 2023

Major Features:

  • ✅ Virtual Threads – Lightweight threads for high concurrency (Project Loom)

  • ✅ Pattern Matching for switch (Finalized)

  • ✅ Structured Concurrency – Simplified thread orchestration

  • ✅ Record Patterns – Pattern matching with records

  • ✅ Sequenced Collections – Ordered collection APIs

  • ✅ Scoped Values (Preview) – Better than thread-local

  • ✅ Simpler main methods with unnamed classes (Preview)

🔍 Why it matters: Java 21 is a game-changer for scalability and concurrency, especially in cloud-native and high-performance applications.

Recommendation: For new projects, use Java 21. For existing Java 8 projects, consider upgrading to at least Java 17.

💬 Have you already upgraded to Java 17 or 21? Share your experience in the comments below! 

Wednesday, 28 May 2025

Retag an existing ECR image

Sometimes you need to retag an existing AWS ECR (Elastic container registry) image to the latest in order to deploy it as the latest.

 
Use Power shell for these commands

1. Get a Specific Image from ECR by Digest


$Image = Get-ECRImageBatch -ImageId @{ imageDigest="sha256:5cf0bd5fa566c49bba44e9fab18bf340bff5f3ef224217a6f13e43321ce9" } -RepositoryName jagdev-poc/service


2. Extract the Image Manifest


$Manifest = $Image.Images[0].ImageManifest


3. Re-tag the Image with "latest"


Write-ECRImage -RepositoryName jagdev-poc/service -ImageManifest $Manifest -ImageTag latest


4. List All Images in the Repository

Get-ECRImage -RepositoryName jagdev-poc/service

Thursday, 15 June 2023

git pull error :error: remote ref is at but expected

Today I faced strange GIT error while running GIT pull command.

error: cannot lock ref 'refs/remotes/origin/Feature/Performance_Fix': is at 121133f24b3eda9c7167c7be2b0f31d282b0bbb2 but expected 58840e344e3d301761c726e4f833b83f6b261ecb

Solution : 

Run below commands to fix this issue (Update the object name stored in a ref safely, used this to delete the reference) 

git update-ref -d refs/remotes/origin/Feature/Performance_Fix

git pull


Thursday, 8 June 2023

Error : The specified type member 'Date' is not supported in LINQ to Entities

I was trying to use Date property of DateTime field in LINQ query but got this error.

Message = "The specified type member 'Date' is not supported in LINQ to Entities. Only initializers, entity members, and entity navigation properties are supported."

Example query : 

var query = from employeeRecord in _context.EmployeeRecord 

                   where (employeeRecord.StartDate.Date== currentDate)

Solution : Use DbFunctions.TruncateTime to truncate time part from a DateTime.

Updated Query : 

var query = from employeeRecord in _context.EmployeeRecord 

                   where (DbFunctions.TruncateTime(employeeRecord.StartDate) == currentDate)

Saturday, 1 April 2023

Error while upgrading Azure function to .NET6

I was  upgrading a Function App from using version 4.0.0 of Microsoft.Azure.WebJobs.Extensions.Storage to 5.1.0 and then the app crashed on startup with the following error: 

 Error : A host error has occurred during startup operation 'dea811a2-8241-4581-a014-2f94a0aad978'. [2023-03-31T22:00:31.493Z] Microsoft.Azure.WebJobs.Extensions.ServiceBus: Could not load type 'Microsoft.Azure.WebJobs.ParameterBindingData' from assembly 'Microsoft.Azure.WebJobs, Version=3.0.34.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. 

Solution : 
  1. Downgrade to, "Microsoft.Azure.WebJobs.Extensions.Storage" version: 5.0.1 
  2. Clean the solution and run it

Thursday, 19 January 2023

InvalidOperationException: Can't use schemaId for type The same schemaId is already used for type

 After adding new bean to project I got below error during startup


13:44:19:254 ---> System.InvalidOperationException: Can't use schemaId "$Employee" for type "$staff.Employee". The same schemaId is already used for type "$test.Employee" 13:44:19:254 at Swashbuckle.AspNetCore.SwaggerGen.SchemaRepository.RegisterType(Type type, String schemaId) 13:44:19:254 at Swashbuckle.AspNetCore.SwaggerGen.SchemaGenerator.GenerateReferencedSchema(DataContract dataContract, SchemaRepository schemaRepository, Func`1 definitionFactory) 13:44:19:254 at Swashbuckle.AspNetCore.SwaggerGen.SchemaGenerator.GenerateConcreteSchema(DataContract dataContract, SchemaRepository schemaRepository) 13:44:19:254 at Swashbuckle.AspNetCore.SwaggerGen.SchemaGenerator.GenerateSchemaForType(Type modelType, SchemaRepository schemaRepository) 13:44:19:254 at Swashbuckle.AspNetCore.SwaggerGen.SchemaGenerator.GenerateSchema(Type modelType, SchemaRepository schemaRepository, MemberInfo memberInfo, ParameterInfo parameterInfo) 13:44:19:254 at Swashbuckle.AspNetCore.SwaggerGen.SchemaGenerator.CreateArraySchema(DataContract dataContract, SchemaRepository schemaRepository) 13:44:19:254 at Swashbuckle.AspNetCore.SwaggerGen.SchemaGenerator.<>c__DisplayClass10_0.b__1() 13:44:19:254 at Swashbuckle.AspNetCore.SwaggerGen.SchemaGenerator.GenerateConcreteSchema(DataContract dataContract, SchemaRepository schemaRepository) 13:44:19:254 at Swashbuckle.AspNetCore.SwaggerGen.SchemaGenerator.GenerateSchemaForParameter(Type modelType, SchemaRepository schemaRepository, ParameterInfo parameterInfo) 13:44:19:254 at Swashbuckle.AspNetCore.SwaggerGen.SchemaGenerator.GenerateSchema(Type modelType, SchemaRepository schemaRepository, MemberInfo memberInfo, ParameterInfo parameterInfo) 13:44:19:254 at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.GenerateSchema(Type type, SchemaRepository schemaRepository, PropertyInfo propertyInfo, ParameterInfo parameterInfo) 13:44:19:254 --- End of inner exception stack trace --- 13:44:19:254 at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.GenerateSchema(Type type, SchemaRepository schemaRepository, PropertyInfo propertyInfo, ParameterInfo parameterInfo) 13:44:19:254 at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.GenerateRequestBodyFromBodyParameter(ApiDescription apiDescription, SchemaRepository schemaRepository, ApiParameterDescription bodyParameter) 13:44:19:254 at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.GenerateRequestBody(ApiDescription apiDescription, SchemaRepository schemaRepository) 13:44:19:254 at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.GenerateOperation(ApiDescription apiDescription, SchemaRepository schemaRepository) 13:44:19:254 --- End of inner exception stack trace --- 13:44:19:254 at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.GenerateOperation(ApiDescription apiDescription, SchemaRepository schemaRepository) 13:44:19:254 at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.GenerateOperations(IEnumerable`1 apiDescriptions, SchemaRepository schemaRepository) 13:44:19:254 at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.GeneratePaths(IEnumerable`1 apiDescriptions, SchemaRepository schemaRepository) 13:44:19:254 at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.GetSwagger(String documentName, String host, String basePath) 13:44:19:254 at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider) 13:44:19:254 at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context) 13:44:19:254 at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)

Solution : 

The only change needed is in your Startup.cs inside the method ConfigureServices.

You should add the following:

services.AddSwaggerGen(options =>

{

    options.CustomSchemaIds(type => type.ToString());

});

Wednesday, 7 December 2022

How do I fix dependency conflicts in npm install?

Today I was working on a front end app. I faced below error while running npm install command.


npm ERR! Conflicting peer dependency: @angular/core@6.1.10

npm ERR! node_modules/@angular/core

npm ERR!   peer @angular/core@"^6.0.3" from @angular-redux/router@9.0.0

npm ERR!   node_modules/@angular-redux/router

npm ERR!     @angular-redux/router@"^9.0.0" from the root project


Fix for Conflicting peer dependency in node.js

  • Downgrade the npm version to the previous version.
  • remove the node_modules folder.
  • remove package-lock.json.
  • please do npm install one more time to do a fresh installation of the dependency.