Java ages too, as everything. Modernise legacy java applications to benefit more of your business services.

Many organizations struggle to keep their java applications running while also trying to innovate. Development and operations teams must provide new demands for application services and also maintain, operate, and improve existing application portfolios. Unfortunately like everything, Java also gets its age. This tutorial is a quick introduction to modernize your legacy Java application to a modern one, without much hassle.

According to a java version survey in Jetbrains, Around 20% of all java applications still use java versions below 8 (Which we might definitely call as legacy applications). Around 83% of java applications are using java 8, as a guess getting its age and getting being slowly legacy applications, as recently java 14 is released.

That’s a quick tutorial to update your java application to use a recent version and library. Just a warning beforehand, these kinds of modernization attempts might be really hard and cumbersome for really huge applications, and for these kinds of legacy applications, you might get a quote from Oreon’s java Legacy Software modernization service.

Another warning to mention before modernizing application structure and libraries to use recent java versions, these kinds of modernization should mostly be done in coordination with operating system modernization. Maybe it is time to think about containerizing your architecture using our DevOps Consultancy services.

During a modernisation process of a legacy application, keep these things in mind:

  1. Always Start with a working/running application!
  2. Always Take small steps
  3. Upgrade one library or version at a time
  4. Always change one thing at a time
  5. Always Write tests when not already in place.
  6. In case something is broken, just revert back to a working version.

1.) Define an achievable and optimum target java runtime version to modernize your application to.

That might be difficult to decide the target optimal runtime, but mostly we might define a target java runtime, though this decision step is dependent on the project.

  • If your project uses legacy java classes com.sun packages, it might easier to upgrade up to java 7. to migrate above java 8, you will need to convert these old blocks to their more recent counterparts (at this stage it might be a nightmare).
  • java 8 is mostly a performant release comparing to older ones, as Oracle integrated BEA’s JVM into Oracle’s JVM in that release.
  • To get a better overview, you might need to check also project libraries to find, up to which java version they support. Some libraries might came to end to support or development, so in that case, you might need to replace these libraries with recent counterparts with the same functionalities.

2.)Use of a software project management and build tool (if your legacy application still does not use any)

The project management and comprehension tool’s primary goal is to allow developers to comprehend the complete state of a development effort in the shortest period of time. Additionally they standardize the software development lifecycle, independent of the developer, environment. version. Main features of software project management tools are :

  • Making the build process easier and more standardized.
  • Providing a uniform build system, independent of the developer and operating system and environment.
  • Providing quality management of the software project.
  • Encouraging better development practices and minimizing the bugs in the software development lifecycle.

Check if your project does not use any of the modern project management tools like Maven or Gradle. If using Ant build tool, you might also consider an upgrade, as it is pretty aged currently.

If the project is bigger than normal, I would suggest using Gradle as it provides better scripting capabilities and more recent. A comparison of both tools might be found in Dzone’s Gradle vs Maven article.

To convert your project into maven project layout, you might refer our converting to Maven Tutorial.

To convert your project into the Gradle project layout, you might refer our Using Gradle as a project management tool tutorial.

3.) Legacy java Modernization Process

Upgrade auxiliary libraries.

  1. To update each library, just search the given library name in the Maven repository and copy or update the selected library version in your project management file (pom.xml or build.gradle)
  2. After each or multiple updates, Rebuild the project just to check if the build fails or succeeds.
  3. In case the build fails, you might need to refer to the failed library’s update documentation. Most probably, For small libraries, small code changes for some deprecated classes or method names. might solve the issue. Furthermore, you might need to dig the recent method or class names within the same package, or referring the migration tutorial (if any ) would to a better job.

Update fundamental classes and configuration files.

  1. If the project uses Spring frameworkSpring security, or other spring-related frameworks, it might be a good practice to start with updating spring libraries. To updating spring libraries, it would be beneficial to refer to their migration guide. The migration might be totally different regarding to the source and target version.
  2. Just start with updating the libraries in pom.xml or build.gradle files with the final versions found in Maven repository.
  3. To upgrade spring libraries, you would need to update the XML TLD and namespace declarations in spring-related configuration files, if your application uses XML based configuration (Most probably it does).
    • Mostly upgrade from Spring Framework 3.2- to 4+ should be as straightforward as a change of version numbers in your build file. Though you may have to upgrade some third-party dependencies to a recent enough version (e.g. Hibernate, Apache POI, Quartz, Jackson, Tiles, Struts).
    • Upgrade from Spring Framework 3.2- to 5+ would be much more cumbersome and painful, but it might be worth it. You would get too many configuration mismatch errors and class and method mismatches as most of the deprecated methods and classes are removed from spring 5 libraries. During this process, you would get compile errors which you may fix by referring to the spring migration guide and definitely some runtime exceptions which you may fix by finding the place of the issue through the exception messages.
    • Another issue with Spring 5 migration would be related to Hibernate updates, if your project depends on. Spring 5 libraries are dependent on the Hibernate 5 library and you have to update the hibernate related Data Access layer repository classes.

Leave a Reply